0
Question about objects and classes for school assignment
I'm working on an assignment using if-else and loops for my Programming and Algorithms class. For the assignment I have to make a version of the dice game Pig where the user plays against the computer. One of the requirements is that it needs "an appropriate computer class that should play the computers role in the game." Could someone explain how this would be done or possibly give an example code?
1 Respuesta
+ 9
The "computer" class is literally going to be an object representative by the name "computer", now I don't know what the Pig game is or what it's like, but I can give you an example of the computer class:
class Computer {
private:
// What the user doesn't need to know about.
public:
// What the user should know about. For example:
int die_roll (int die_number) {
return(rand() % die_number);
}
}
As for the rest, it will be up to you to decide what it needs and what it doesn't, GL though!