Steve, Jon, Jennifer, and Kelly own dogs and take their dogs to the park between 12:00 noon and 4pm. There are four activities the owners can do while at the park. These are as follows: Play catch with the dog, clean the dogs poop, walk the dog, or a fourth activity. The owners can only be doing one activity at a time, and the order that they do activities should be random. The park has two tennis balls for playing catch and one pooper-scooper. This means that only two owners can be playing catch at once, and only one owner can be cleaning poop at a time. If an owner tries to play catch or clean poop and can't because the tennis balls or the pooper-scooper are being used they should do their fourth activity until a ball or the pooper-scooper becomes available. If there are two or more owners that are waiting for the same object then the owner that started to wait first should get the object first (FIFO). Then they should start the activity they originally tried to do. The time the owners take to do each activity varies. The owner activity lengths, in minutes, are as follows: Owner Catch Clean Walk Steve 5 2 10 Jon 8 2 4 Jennifer 10 4 8 Kelly 1 2 6 Each owner also has a fourth activity they can do but the activity and activity lengths vary from owner to owner. The lengths should be random whole numbers. Steve reads between 2 and 8 minutes, Jon plays game-boy between 4 and 6 minutes, Jennifer cross-stitches between 1 and 5 minutes, and Kelly crochets between 6 and 10 minutes. If the owner does their fourth activity because it was randomly chosen then their time should be random as well, according to the above description. If the owner does their fourth activity because they are waiting for a ball or the pooper-scooper, then they should do the activity until the object becomes free and then start doing that object's activity. You should record what owner begins which activity at what time. You should save all this information to one file. Each record in the file should be on a separate line and each record should be in the format 'Owner:Time:Activity.'
Since it's not homework, that is even more of a reason to let you do most of it yourself. Have you run into any particular problems with your solution yet? The more specific your questions the better we are able to give you specific answers.
Let me just give you some background. I applied for a Software QA job and at the end of the interview the gave me this story problem and told me I had until Friday to do it. I guess you could call it homework but instead of me paying tuition to be given a problem like this it may result in me getting paid. My skills and experience as a java programmer are lacking. I have found it hard to really grasp java without having real life experience and I have found it hard to get a job without that experience. Having given you that background let me tell you I have wrote 2 classes and I found some code for the random number generation. I don't know if you want me to e-mail you the code or if you want me to post it here. I will say this again and again - your help is very much appreciated.
I'm thinking you won't have this job for long if you can't knock out a solution to this problem in a couple of days. Please understand, I'm not being flip here, but when an employer hands out a problem like this to a candidate, it's usually because you need to have the skills the problem requires of you to be a success on the job. All I can say is study up on your multithreading. Each dog/owner pair gets its own thread and the ball/pooper scooper represent resources to which exclusive access must be had by the using thread. That'll help you home in on what you need to study... Have fun! sev