Forums Register Login

Java Classes

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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?
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 994 times.
Similar Threads
Random Card Problem Check
Probably a simple answer
Wanting to ask user to keep "inputting" at the command prompt until a condition is reached
Creating a method that takes no Arguments
coin flip assignment help
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:59:06.