Assignment help

Assignment help

The first part:
This program is a dice generates the number from 1 to 6.
Each number is associated to a prize like 1 is a car, 2 is a Lunch, 3 dinner and so on

No test driver needed
Im to construct this class implementation and specifications.

This is what ive done so far....

Last edited on
Well, lets start here:

1
2
3
4
5
6
7
void MagicNumber::setNumber(int)
{
}

void MagicNumber::setItem(string)
{
}


What do you think is happening with these two functions? What is the point of these two?
Since its void, it will have no reurn?
There is no need to provide a get & set function for every private member variable. Try to provide only the public functions that are necessary - in this case it is the generateNumber function. It sets the number variable and returns it, so the get & set functions aren't needed.

If you had a get & set for each private member variable, then you might as well make them all public !!!

Now you just need a switch statement to decide what the prize is.

Since its void, it will have no [sic]reurn?


Yes. Essentially all these two functions do is assign the value of the argument to the member. Its good practice because if in the future you want to change the member variables or add more functionality, you don't need to re-write all the other code: The class interface stays the same so that any other programmers using your class don't have to worry about changing anything.
Topic archived. No new replies allowed.