Methods


#1

I'm completely stuck on methods 1 I have no idea what to put and even when I do give code I still get it wrong what do I do?


#2

Is this the step that you are stuck on:


#3

yes thats what i'm stuck on


#4

but i have that and it says it's wrong


#5

That's not good!

Could you give me a screenshot of what you are seeing, error message and code?


#6

There's no code when i do it. The message is "Did you create the bark method? Place it between the constructor and main method."


#7

You must have some code?? -- In the panel where your editor is?


#8

class Dog{

int age;

public Dog(int dogsAge) {

age = dogsAge;

}

public void bark() {

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

}

public static void main(String[] args) {

Dog spike = new Dog(7);

}

}


#9

That is the code I have


#10

I can't spot anything wrong with that. You could try resetting the exercise - be careful to do it on this exercise, not an earlier one because it will reset everything beginning from where you are.


#11

Ok how do i reset? Because exiting out of everything and coming back didn't work.


#12

It's under the Get Help button.


#13

I tried resetting and it still won't let me move on


#14

Could you give me a screenshot of what you are seeing, the whole web page, instructions, error message and code?


#15

@matthew_chalmers

hi there. The issue is it is checking for the exact output of step 1.

so you first need to enter:

  public void bark() {

  }
  • run the code.
  • add the println

  public void bark() {
        System.out.println("Woof!");
  }
  • run the code again

This sucks because it is inconsistent with the other lessons which don't seem to be checking for answers as strictly which allows you to enter all the steps at once