• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a class to output print within another class?

 
Brian Mart
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This seems like a basic problem, but I am having a lot trouble solving it. Basically, I need to output all of the rules from the class rules if the criteria are met in the nested if statement in the class Craps. There is more code after rules, but it is irrelevant. My compiler tells me "cannot return a value from method whose result type is void".
I realize I could simply copy and paste the entire rules class to the spot in the nested if statement, but this is not kosher according to my professor. Can someone point me in the right direction please

 
Panagiotis Kalogeropoulos
Rancher
Posts: 99
Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need to call return when you want to call also the rules method. If you omit the return keyword your code will work fine.

Also something very important: you should compare Strings using the equals method, not the == operator.
 
Brian Mart
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was so simple.... Thanks!
 
Panagiotis Kalogeropoulos
Rancher
Posts: 99
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic