Image

Imageoge_retla wrote in Imagecpp

Hey there,
I was wondering if anyone here could help me out. I'm working on this program for a prof. I thought it would be very easy, since I've done much more complicated things in the past, but this one part is turning out to be a bitch.

Anyway, the basic idea of the thing is there is a race. Any number of players have to be able to join and specify the color of their cars. They roll the dice and move along the board, and the first one to get to the 100th space wins. The only class we're allowed to have is a Car class, to represent each player. I used a vector of cars in main() to allow as many people to join as they wanted. The program so far was very, almost embarassingly, easy.

Anyway, now she has asked me to do the following. Within the Car class, I have to have a member function that keeps track of what place each car is in. At the end of each "round" (after all players have had one turn), it needs to list the cars in order of what place they're in. If I could do this in main() where I could just access my vector of cars and compare their positions on the board and order them that way, I'd be fine. But she wants me to do this -inside- the class. And honestly, I can't think of any way to do that. Maybe I'm just overtired and missing the obvious, but not sure.

Does anyone have any ideas? Feel free to ask me any questions you need...