Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Elevator Errors

 
Alex Munoz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




I get errors saying it cannot find symbol elevator1 and I am unsure of how to reformat it so that it works. Please point out all other errors that you see! I'm really grinding through this.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What is elevator1 in your Elevator class? It's not declared anywhere (nor it should be) and you are trying to use it as an object. That's why you are getting that error (which says the same thing I just wrote). You are trying to do the same thing at lines 60 and 64 of the code you posted. Also, at lines 60 and 64 you are using getDirection() method as a field and those if(s) can be avoided with switch making your code look better.

In addition setTargetFloor(...) method is just wrong and not doing what you (probably) wanted it to do.
 
Alex Munoz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would I change elevator 1 to? I can't think of any alternative.

Would I change setDirection to getDirection to fix that?
 
Paul Witten
Ranch Hand
Posts: 86
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Munoz wrote:What would I change elevator 1 to? I can't think of any alternative.

Would I change setDirection to getDirection to fix that?


I think he means here Alex:



I think he means to just get rid of "elevator1.setDirection()" and replace with "setDirection()". That is normal and customary when calling a method from within the class. You're not calling setDirection() from outside the class. You're calling from within, so the class knows how to find setDirection(). It's a member of "this", meaning the current instance of the class.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic