This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Joseph Meier
over 10 years

Override OOP, code works, won't pass me. What am I missing.

OOP 4/8,

Keep getting a message that says my $bicycle isn’t an instance of the Bicycle class, but the code wouldn’t work if that were true, and the code works fine. What am I missing? Code below.

Answer 52970ab8548c356a400026c3

2 votes

Permalink

class Vehicle { public function honk() { return “HONK HONK!”; } } // Add your code below! class Bicycle extends Vehicle{ public function honk() { return “Beep beep!”; }

        }
    $bicycle = new Bicycle();
     echo $bicycle-> honk();
.....You were  supposed to return "Beep beep!"  but u returned "ring ring"
points
Submitted by Fridah Nyagu
over 10 years

Answer 52a0f60152f863ab51000c36

2 votes

Permalink

found that it was missing () after Bicycle in $bicycle instance <?php class Vehicle { public function honk() { return “HONK HONK!”; } }

class Bicycle extends Vehicle {

public function honk() { return “Beep Beep!”; } } $bicycle = new Bicycle(); //<———–here echo $bicycle->honk(); ?>

not sure if its correct since im a newbie but passed..lol

points
Submitted by rayzraven
over 10 years

1 comments

bit_crusher about 9 years

this was my problem, thank you

Answer 529966ebabf8211d680053aa

1 vote

Permalink

have the same problem <?php class Vehicle { public function honk() { return “HONK HONK!”; } }

    class Bicycle extends Vehicle {
  public function honk() {
      return "Beep Beep!";
  }
}
$bicycle = new Bicycle;
echo $bicycle->honk(); 
   
  ?>

Message –> Oops, try again! It looks like $bicycle isn’t an instance of the Bicycle class. Check the Hint if you need help!

points
Submitted by Pavel Asanov
over 10 years

4 comments

zen over 10 years

sometimes the editor/parser lags. did you try pressing the save & submit button again?

Fridah Nyagu over 10 years

your should return “Beep beep!”; instead of return “Beep Beep!”;

zen over 10 years

meh, missed that _

Harika over 10 years

you have to add $bicycle=new Bicycle();i think it will help you.

Answer 52a41c9f7c82ca71ed002dcb

0 votes

Permalink

Thanks everybody.

points
Submitted by Md. Oliullah
over 10 years