Vintage Mustang Forums banner

1 - 3 of 3 Posts

·
Registered
Joined
·
1,258 Posts
Discussion Starter #1
Ok in my trivia game I have to use atleast 1 class... What would be an example of a use of a CLASS in a trivia game?
 

·
Registered
Joined
·
2,374 Posts
I'm assuming you are meaning class in an OO sense. So, if I were doing it, of course you would have a Game class. Since you are having Categories, there should be a Category class, and you can have a class that represents the question.

The Category class would have a collection of questions (I'm a Java programmer that hasn't done C++ in about 7 years so you'll have to translate class types for me). The Question class would have attributes of the question and answer (you could have an array of possible answers if you want to make it multiple choice, and you could get fancy with true/false answers too).

Sorry, I can't get a UML diagram to paste in this answer box! /forums/images/icons/smile.gif
 
G

·
Guest
Joined
·
0 Posts
void main()
{
Game* myGame = new Game();
myGame->play();
}


where Game is your class that contains the play code...

class Game
{
public:
Game();
~Game();

void play();
// etc.
};

You could then make other classes for categories, which would be instantiated within Game.
 
1 - 3 of 3 Posts
Top