View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Graduation exercise from cplusplus.com

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Northern  Members

Posted 11 August 2012 - 10:53 AM

Hey.
So, I was doing some simple C++ exercises the other day and I found a very interesting one I'd like to complete.

http://www.cplusplus.com/forum/articles/12974/
(scroll down to the last exercise called Graduation).

It is as difficult as it is fun and it might be too early for me, but I'd still like to attempt it.
I realize that I first need to create a struct that will hold all the properties of bunnies such as sex/name/age.
What do I do next? How can I loop through the created instances of this struct? Every turn, I have to check if a bunny is too old/ready to procreate/whatever, and so aren't I supposed to have some kind of way to loop through the list of existing instances in the same way as I'd do it with an array? If not, then what am I missing?

I'm not asking for a walkthrough here. Just general tips on how to get started.

Posted 11 August 2012 - 11:42 AM

I suspect this is what you missed:

Write a program that creates a linked list of bunny objects.

### #3Northern  Members

Posted 11 August 2012 - 12:12 PM

I see. Could you please elaborate on that? I'm a complete beginner.

### #4Neometron  Members

Posted 11 August 2012 - 12:15 PM

"Write a program that creates a linked list of bunny objects."
With an array you could jump to any position of that array, however a link list you must start at the beginning node and transverse through each node in order to reach the desired node. Each node will have a pointer to next node and a structure/pointer to the data it contains.

Start by laying out the framework of the application.

Main
Initialization
Main Loop
User Input
Bunny Update Loop
Change State
Create New Bunnies
Kill Current Bunny
Mass Murder Bunnies
Sort Bunny by Age
Display Output
File Output
Cleanup
Exit


I have noticed that advanced classes is part of the requirements for the exercise. A class CBunny would be good candidate for this instead of a struct. For the link list, pass a pointer of CBunny as the data.

Good Luck ;)

Edited by Neometron, 11 August 2012 - 12:17 PM.

### #5Northern  Members

Posted 11 August 2012 - 12:28 PM

Alright, it's clear now! Thanks.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.