I am supposed to implement a queue for 25 where each customer receives a number, a time of arrival and a full name. I'd understand how to do it if I could use a list but I'm supposed to use a one dimensional array for a cyclical queue for the implementation. My question is, how am I supposed to save multiple information in each customer ? Do I still need to create a seperate list ?
CodePudding user response:
how am I supposed to save multiple information in each customer ?
I think you want to create a blueprint/class for a customer to store all the related information.
class Customer {
private String name;
private int number;
...
// setters, getters to store and retrieve information.
}
Do I still need to create a seperate list ?
No, you don't need to create a seperate list, you can create a list of Customer
's like this
List<Customer> customers = new ArrayList<Customer>();
you might want to look at this for more info on CircularQueue
CodePudding user response:
how am I supposed to save multiple information in each customer ?
You should use struct
. Take a look at this tutorial to understand Structures in C. Your struct can look something like this :
//each customer receives a number, a time of arrival and a full name.
struct customer {
int num;
int time;
char name[100];
};
Do I still need to create a separate list?
No, you don't need a separate list for each of them. Once you have a struct
defined, you should create a list of these structs.
struct customer customer_queue[25];