Originally Posted by
JonSnow
... It just intrigued me that the professor thought it was possible to print " You have rolled a six and four"
But the
toString() method in the assignment just returns the String "one", "two", "three", "four", "five", or "six" depending on the integer value of the die 1, 2, 3 4, 5, 6. It does not keep track of two tosses of the die and report both values.
Why not just make an array of Strings containing {"one", "two",...,"six"} and have the
toString() method return one of those elements depending on the value of the die?
It seems to me (because of the requirement of the
equals() method) that your game will have two different instances of Die objects. In fact, since you have now posted a link to the assignment, I see the following:
"The DoublesGame main method uses two Die objects and uses the roll, equals, and toString methods correctly."
Toss them both using each object's
roll() method. Craft a message using the
toString() method of the two Die objects, and then compare the objects for equality to determine whether this play is a winner.
Bottom line: Read the
entire assignment
before starting to write code. Make sure you understand the assignment. Use any helpful hints that were given.
Post-bottom-line comment (if that's allowed):
The reason that I jumped on craps as the game is that whenever anyone says "dice game" to me, I automatically think "Craps! Let's play!" The Doubles game of your assignment would be a fair game if the payoff were 6-to-1 rather than 2-to-1. You could probably make a lot of money on the Street by offering 4-to-1 or 5-to 1-odds. (Assuming, of course, that the other players were idiots. That's what most street games and all casino games assume: The players are idiots.)
I am always disappointed when educators create assignments like this that could actually be educational (by making it a fair game and maybe even explaining why the odds are what they are) but come up with an exercise in programming that has no real pedagogical payoff beyond the programming language aspects.
Cheers!
Z