Quote:
Originally Posted by codylee270
So, I'm assuming I need to randomly generate 1000 numbers, b/w 1 and 1440, I'm guessing those should be unique. For the customer names I'll use 2 string arrays, read in each name from the file into an index, probably upon execution of the program (in the main() function).
|
I think you're looking at this the wrong way. Instead of trying to generate random data for 1000 customers, create a function that will create a single customer object with random data. Then repeat that function 1000 times.
Quote:
Originally Posted by codylee270
I'm not sure what to do about randomly creating the method of payment based on percentage? Anyone have any good ideas?
|
Consider a random number generator that generates a number from 1 to 100. There will be a 20% chance the random number will be between 1 and 20, no?
Quote:
Originally Posted by codylee270
Also, what should I do about initializing all the cusomters. Should I make the class, as reccomended, and use a loop
|
Look up the factory design pattern. It would be neater to do it like so:
CustomerFactory factory = CustomerFactory(firstnames, lastnames, etc...);
for (int i = 0; i < 1000; i++)
{
customers[i] = factory.newRandomCustomer();
}
Quote:
Originally Posted by codylee270
How could I sort the deli queue alphabetically (if last name and first name are each stored in a separate array), using the last name array, and have the associated first name array be changed to reflect the sort. Or if there is an easier way to perfom the deli line queue sort, please let me know. I'm thinking I'll need the full 40% of customers in line before then?
|
Why is this difficult? You'll have an array or vector of customers representing the deli line queue, no? And each customer object will contain their firstname and lastname, no? So its straightforward to sort them into alphabetical order and pop off the top customer.
Quote:
Originally Posted by codylee270
More importantly, how do I keep up with all the times in general so everything goes in order. This seems like the hardest part of the project and, to me, the most confusing.
|
Surely each customer object will keep track of how much time they need? You could write some simple functions so you could ask each customer when they start shopping, how long they take to pay, and so forth. Your "Megastore" object would presumably coordinate and shuffle customers in and out of queues, and add to an internal counter than keeps track of time.