Keeps giving me errors dont know whats wrong now


#1



Replace this line with your code. 

class Dog{
int age;  

  public Dog(int age){
    age = age;
  }




	public static void main(String[] args) {
  Dog Dog = new Dog(spike);
    
	}

}


#2

Exercise 5. Classes: Constructor Parameters has asked for your Dog constructor to have a parameter called dogsAge, you have missed that detail. You've used age instead:

public Dog(int age)

On the next line, don't forget to assign dogsAge to age.

Exercise 7. Objects is where you use your new constructor to create a new Dog object. You've got that line a bit mixed up. You have this:

Dog Dog = new Dog(spike);

To create a Dog named spike you would start off with:

Dog spike =

Then you would use new Dog() to pass spike's age in as a parameter rather than his name. Remember the constructor, it is expecting you to send it a dogsAge, not a dogsName.


#3

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