File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Classes" Watch "Java Classes" New topic

Java Classes

Vincent Mule

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.


Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

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

Joined: Jun 19, 2010
Posts: 825

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:
subject: Java Classes
It's not a secret anymore!