Results 1 to 3 of 3
  1. #1
    darkblue24 is offline Member
    Join Date
    Jan 2010
    Posts
    36
    Rep Power
    0

    Default operator || cant be applied to OlimpicFrog, boolean

    Hi

    I cant compile my code cause of error:

    "operator || cant be applied to OlimpicFrog, boolean"

    Error is in method:

    Java Code:
        /**
        * 
        * Moves to the home position and then moves right by the number of times indicated by the class constant RUN_UP,
        * Performs a jump; Next Increments the receiverís medalCount by one and then checks the value of the class variable currentLeader.
        * (To become the current leader, an OlympicFrog must have more medals than the current title holder. 
        * So if currentLeader is null or ifcurrentLeader references an instance of OlympicFrog whose medalCount isless than the receiverís,
        * then the method should set currentLeader to the receiver.)
        */
       public void jump()
       {
          super.home();
          for (int move = 0; move < OlympicFrog.RUN_UP; move++)
          {
              super.right();
            }
          super.jump();
          this.incrementMedalCount();
          
          if ((OlympicFrog.currentLeader = null) || (this.getMedalCount() > OlympicFrog.currentLeader.getMedalCount()))
          {
              this.OlympicFrog = OlympicFrog.currentLeader;
            }
          
          
        
       }

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    (OlympicFrog.currentLeader [b]=[/b] null)
    You want the equality operator (==) instead of the assignment operator (=).

  3. #3
    darkblue24 is offline Member
    Join Date
    Jan 2010
    Posts
    36
    Rep Power
    0

    Default

    Thank you. That helped but now I have another error in that method in statement:

    Java Code:
              this.OlympicFrog = OlympicFrog.currentLeader;
    Error says:
    Cannot find symbol - variable OlympicFrog

    What I am trying to achieve in that statement is to set currentLeader to the receiver but I'm not sure how to do that.

Similar Threads

  1. Replies: 2
    Last Post: 11-26-2010, 02:12 AM
  2. Replies: 3
    Last Post: 12-01-2008, 05:40 AM
  3. Replies: 4
    Last Post: 11-27-2008, 06:09 AM
  4. Error: cannot be applied to (java.lang.String)
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 06:33 AM
  5. Replies: 1
    Last Post: 08-01-2007, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •