I need help I have a problem with the Constructor Dog problem on Java Script


#1

Here is the link to the exact exercise where I am having difficulties

https://www.codecademy.com/en/courses/learn-java/lessons/object-oriented-programming/exercises/classes-constructors?action=resume

Here is the problem

  1. Add a class constructor called Dog to the class.

Note: If you're getting an error in the console about a main method, include the following code within the Dog class (it will be explained later in this lesson):

And This Is My Code

class Dog {

//The class constructor for the Dog class
public Dog() {

public static Dog void main(String[] args) {

But I get an error can someone give me the proper code so that I can move on lol (:

#2

Hey there.

A couple things to note here.

Your dog constructor must not contain anything else for the moment. It should just be an empty constructor. ie.

public Dog() {

}

Also, there is a problem with your main method. You need not have to include Dog in the method signature. Our main method should always have the basic outline shown below:

public static void main(String[] args) { // Dog omitted 

}

Last thing. I don't see a closing brace for the Dog class. Make sure your closing curly brace is after everything else. Including the main method and it's closing curly brace.

All in all, it should look like this:

class Dog { // Dog class begins

   //The class constructor for the Dog class
   public Dog() {

   }

   public static void main(String[] args) {

   }
} // Dog class ends

#3

I wrote the same code which you have written but it didn't work.It's showing The following sentences on the bottom of the screen:

Did you create a Dog constructor? Use the example to help you.

What can I do now?


#4

First thing I would say to try is:

Copy your code > bottom right hand side of screen ("Get Help") > reset this exercise. Paste your code back in and try to run it.

If not, would you mind taking a screenshot with the code, instructions, console and error message in view?

Thanks


#5

Thank you so much angusbeef it worked for me I am very grateful for your help lol if it was not for you I would not have made it this far lol thank you so much :D!!!!!! <3


#6

It Works!!! Thank You So Much LOl :slight_smile:


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.