| Author |
Java Classes
|
Vincent Mule
Greenhorn
Joined: Oct 04, 2012
Posts: 14
|
|
So this project requires me to create a class that mimics flipping a coin. I am having some trouble with my methods. For example, when I try to run the Coin tester, I get errors on the coin1.getNumTails() and coin.1reset(); sections of the Coin Tester program. I'll attach my Coin class so you can tell me what I'm doing wrong.
COIN TESTER PROGRAM
COIN CLASS
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 5790
|
|
Hi, Vincent, and welcome to the Ranch!
A couple of tips to help you get the most out of this site:
1) UseAMeaningfulSubjectLine(←click). That way people can get a rough idea of what your question is about at a glance and decide if they want to look into it.
2) TellTheDetails(←click), such as copy/pasting the exact, complete error message and indicating clearly which line causes it, rather than just saying, "I get errors."
Good luck!
|
 |
Kemal Sokolovic
Bartender
Joined: Jun 19, 2010
Posts: 792
|
|
Besides the fact that CoinTester cannot be compiled (as you posted it) the code should work without errors.
Though, that statement in the constructor of the Coin class is not really meaningful to me - you declared String variable local to the constructor and initialized it to empty string. Why would you do that, since you can't use it anywhere outside the constructor?
Edit: And why getNumHeads() and getNumTails() are declared to return String? Wouldn't be more appropriate to return integer?
|
The quieter you are, the more you are able to hear.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Java Classes
|
|
|