I'm simulating a supermarket, with various checkout lines, and each of them has its own queue, where the customers will be added when they finish shopping. Both customers and checkouts are clases, instantiated in the main class using Arraylists.
ArrayList<Customer> customerList=new ArrayList<Customer>(maxCustomers);
for (i=0;i<maxCustomers;i++){
customerList.add(new Customer(randomItems, randomArrival);
}
I create the checkouts in a simmilar way.
Arraylist<Checkout>checkoutList=new ArrayList<Checkout>(maxCheckoutLines);
for (i=0;i<maxCheckoutLines;i++){
checkoutList.add(new Checkout());
}
The problem here is that I want to create another ArrayList to simulate one queue in each checkout, where I will add the Customers when they finish shopping. I don't know if I should use a multidimensional ArrayList when creating the Checkouts, and I would like to know also how to operate with it when adding the Customers. Regards
Listlater. Equally if the order of the list isn't important you should use theCollectioninterface so you can easily change between any collection later. SoCollection<Customer> customers=new ArrayList<Customer>()new ArrayList<Customer>(maxCustomers);be aware thatmaxCustomersisn't actually the maximum. Its just the initial capacity of theArrayList. It will automatically resize if you add more than that to it (think of it as an efficiency measure and nothing more)