Clouded Sky
05-30-2009, 08:04 AM
So I have to write a javascript program, but unfortunately I don't understand anything the teacher ever says. I'm serious. I'm not the only one either. I have several friends in that class and we're all confused. I was hoping you could help!
I think I have a basic understanding but not really exactly how to go about doing it. Basically I have to do a "model society" with 100 people. Each person has to have a random age between 20 and 50. They also need a 50/50 chance to have children (between 1 and 5) which get counted as full people. Then you age everyone until the hit a hundred and die, and since no new children are being born, everyone eventually dies.
I've been trying to read as much as I can online, but I'm getting stuck.
Make a person class with people objects? Give each object an age and an ID, right? Then basically, run a function that states while age < 100 do age++ and another that when age = 100 they die? Which consists of getting rid of the object? I guess my biggest problem is not knowing how to make ahundred people, and then making their children count as people too. Eff I'm screwed. Does this even make sense?
I think I have a basic understanding but not really exactly how to go about doing it. Basically I have to do a "model society" with 100 people. Each person has to have a random age between 20 and 50. They also need a 50/50 chance to have children (between 1 and 5) which get counted as full people. Then you age everyone until the hit a hundred and die, and since no new children are being born, everyone eventually dies.
I've been trying to read as much as I can online, but I'm getting stuck.
Make a person class with people objects? Give each object an age and an ID, right? Then basically, run a function that states while age < 100 do age++ and another that when age = 100 they die? Which consists of getting rid of the object? I guess my biggest problem is not knowing how to make ahundred people, and then making their children count as people too. Eff I'm screwed. Does this even make sense?