This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Classes

 
Vincent Mule
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic