This forum is now read-only. Please use our new forums! Go to forums
5/8 Help! [RESOLVED]
The following code receives the error message (by Codecademy) Oops, try again. Did you add the final keyword before public function honk() inside the Vehicle class? (Make sure to add it inside Vehicle, and not inside Bicycle.) And outputs (in the console) Beep Beep! Any help would be appreciated! JJ02 Code:
<html>
<head>
<title>Override!</title>
</head>
<body>
<p>
<?php
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();
?>
</p>
</p>
</body>
</html>
Answer 55ba355593767673ec000304
I figured out that I forgot to put the “final” into the code. The correct code is as follows:
<html>
<head>
<title>Override!</title>
</head>
<body>
<p>
<?php
class Vehicle {
final public function honk() {
return "HONK HONK!";
}
}
// Add your code below!
class Bicycle extends Vehicle {
public function "Beep beep!";
}
}
$bicycle = new Bicycle();
echo $bicycle->honk();
?>
</p>
</p>
</body>
</html>
Answer 55fa31ba51b887fa130005a1
Answer 55c38778e39efe4d9b0000b1
I wrote the same code as recomended but I still cant pass this lesson.Code Academy gives me error message?
1 comments
What was the error message, and did you copy the code or type line by line?
Answer 55c4b12d937676a7e6000157
Oops, try again. Did you use the public method honk() … syntax inside the Bicycle class to override the original honk method?
3 comments
Hmm. Let me get back to you on that. It’ll be a bit.
For now, I would try a reset code/ refresh browser, due to the fact the PHP has lots of glitches. If the above doesn’t work, try switching browsers.
I thinks I found it. Look above!
Answer 55c5d56ee39efe28f30006b3
It doesnt help.I tried refreshing and switched 2 browsers.Dont know what to do?
1 comments
Hrmmm. I’ll keep on checking around… I’ll try to get this resolved.
Answer 55c5d600d3292f07e30000ba
I should maybe try going back to the beging of this section?
1 comments
Couldn’t hurt.
Answer 55c5d651e39efe990100031d
5 comments
You might wanna just copy/paste the code.
I got it!
Nothing, man!!! I copied,still nothing.I am really eager to finish the course, but this is crazy.This is what it says: Oops, try again. Did you use the public method honk() … syntax inside the Bicycle class to override the original honk method?
Is there any other way to manage the code?
Does the code above work or no? If not, you might wanna change computers. It works fine for me.
Answer 55c63f8bd3292f47dc00074c
TTT22, I have successfully found the correct code. I have switched some spacing, remove the comment, and walla, a working code. Here it is,
<html>
<head>
<title>Override!</title>
</head>
<body>
<p>
<?php
class Vehicle {
final public function honk() {
return "HONK HONK!";
}
}
// Add your code below!
class Bicycle extends Vehicle {
public function "Beep beep!";
}
}
$bicycle = new Bicycle();
echo $bicycle->honk();
?>
</p>
</p>
</body>
</html>
If the is doesn’t work, I don’t know what will, but this should work. JJ02
1 comments
Your line 15 should read: public function honk(){“Beep beep!”; Other than that, that worked for me (even though I’m pretty certain that’s what I had typed before..!)
Answer 55c7381493767656cc000315
I suppose thats it.Sorry I troubled you.Thanks for your effort.Bye!
2 comments
Its fine, I like to help people. But one thing. I am gonna get this resolved for you. I WILL DO IT!.
With all the courses Codecademy is adding right now, there are most likely tons of glitches around the entire website, not to mention the already glitchy PHP
Answer 55c76b709113cb61230004fb
Alright, I would get rid of the public function "Beep beep!";
and replace it with public method honk()
If that doesn’t work, then well, $%@#! I think it would be best to give it a rest and let me solve it. If worse comes to worst, you might wanna contact the website and tell them your problem.
Answer 55c7bfca93767671d90002d0
Thanks a lot .You are the real deal. Helping people is the virtue of noble people.I l will try it.. At the moment its failing to connect.
1 comments
Yeah, it does that a lot. I didn’t get any work done on your problem yesterday due to that!
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
2 comments
This is confusing why have you left out this: class Vehicle { public function honk() { return “HONK HONK!”;
The code passes, however… That’s weird.