• Post Reply Bookmark Topic Watch Topic
  • New Topic

Incompatibe Types & Symbol Not Found  RSS feed

 
Paul Carter
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know why I'm getting the following errors?

The following are inner classes of the same outer class "public class TowerCode". players[] is an array of Player.

Many thanks in advance

Paul.

final void ProcessButton (int buttonNo){
if (players[0].CheckFood()) {PressBtn();};
//ERROR : Incompatible types - Found Void, Required Boolean

if (players[0].CheckCurse()) {PressBtn();};
//ERROR : Symbol Not Found - symbol method CheckCurse
}



final class Player {
public int food = 25;
public boolean cursed = false;

public boolean CheckFood () {
return true;
}

public boolean CheckCurse () {
return true;
}
}
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The errors seem to indicate that the type of player[] is not the class Player that you have shown. Can you show all of the code?
 
Paul Carter
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Complete class attached Apologies for cra@ppy code - serious learner at work.



[ EJFH: Added "CODE" tags for formatting. ]
[ October 16, 2006: Message edited by: Ernest Friedman-Hill ]
 
Paul Carter
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry error lines since changed to:

if (players[0].CheckFood()) {PressBtn(buttonNo);};
if (players[0].CheckCurse()) {PressBtn(buttonNo);};

same errors

Regards

Paul.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me like there's one extra closing brace at the end of the "CheckCurse" method -- that could mess things up completely.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. You still didn't post the complete code. Class TowerAudio is missing, and there is no loadPlayers(...) method in class TowerCode (you're calling that method in the constructor). Also class Tower is missing

This line gives an error:

The error is "Type mismatch: cannot convert from int to boolean". You probably meant to use "==" here instead of "=".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!