10. Methods II, Did you create the run method?


#1

Hello guys, I'm also having what I this is an incorrect error in the part 1 of this exercise:

Either with or without the comments I get the same error, any ideas?


Instructions 10 first part error
#2

Try to delete comment. It helps!


#3

Comments properly made will not cause a problem.

I do see that you need::
spike.run(40);
After your spike.bark();

My code runs, but I am still getting error statement from the tutorial as to whether the run method created and is placed* between the bark method and main method*. Perhaps I am misunderstanding the meaning of between for this exercise:

If you see anything that could help me, please tell me.
Here is my code:

//Create custom dog class
class Dog {
//Using instance variables to model real life dog
int age;
/* Below the empty class constructor called
Dog()" Modify instance variable called age by adding parameters (options) to Dog constructor which allow data types to be created with specified attributes */

public Dog(int dogsAge) {
//Here the instance variable "age is set equal to dogsAge parameter
age = dogsAge;

}
//
public void bark() {

System.out.println("Woof!");

}

//run method
public void run(int feet) {

// System.out.println("Your dog ran " + feet + " feet!");

}

public static void main(String[] args) {

/*Here the new object is assigned to variable "spike" inside main method */
Dog spike = new Dog(5);

spike.bark();
spike.run(40);

}

#4

Correction - here is code that includes your dog ran 40 feet.

//Create custom dog class
class Dog {
//Using instance variables to model real life dog
int age;
/* Below the empty class constructor called
Dog()" Modify instance variable called age by adding parameters (options) to Dog constructor which allow data types to be created with specified attributes */

public Dog(int dogsAge) {
//Here the instance variable "age is set equal to dogsAge parameter
age = dogsAge;

}
//
public void bark() {

System.out.println("Woof!");

}

//run method
public void run(int feet) {

System.out.println("Your dog ran " + feet + " feet!");

}

public static void main(String[] args) {

/*Here the new object is assigned to variable "spike" inside main method */
Dog spike = new Dog(5);

spike.bark();
spike.run(40);

}

}