Re: Not compiling :(

for some reason it will not compile

What is the compiler message?

Generally the fact that code does not compile should be regarded as a good thing, since, as written, the code does not express what you mean. Responding to the compiler messages is the way to get the code to do what you want. Of course that implies that you have to understand the messages... And that's where forums like this can be valuable - by explaining what the (often cryptic) messages mean.

If you compile the code at the command line the messages will be presented in a pretty standard wording that can be copied and posted here.

Re: Not compiling :(

The method showInfo() is undefined for the type Puppy

This is not a compiler message, but rather a message from the IDE's runtime when you try and run the program which tries (badly) to report to you what the compiler would have said. Remember that Java programs are (1) compiled and (2) run. These are separate steps and you should *seriously* consider compiling and running the program from the command line (console/terminal) where these two actions are not conflated and confused.

Sorry for the rant (but, honestly, NB has a lot to answer for)... In this case the problem is that the Puppy class does not have a showInfo() method. Remember that methods always have a return type (void/int/etc). Without a return type there will be no method, and when you run the program (which you can't really do because it hasn't compiled...) you will get the "showInfo() is undefined" message.

So, add a return type to showInfo().

---

By the way this was the problem in your original code (in two places).

As the comment suggests (by what it doesn't say) the method is not intended to return anything. So (1) use void as the return type and (2) remove the two return statements.

---

Notice that the return type has nothing to do what types are used within the method. It's all about what type of thing (if anything) is returned to the caller. All methods have return types, constructors do not.

My preference for adding javadoc comments reflects something deeper: I already know what I want a method to do before I start to write it. I sympathise with the fact that you are playing about and trying to get a feel for Java's syntax, but it's never too early to adopt the rule that the programmer is in charge. Just hacking about until you get something to compile and run isn't good enough. The program (and each method) should do precisely what you intended it to do.

Re: Not compiling :(

Same deal as before: Decide what you intend the method to do. This will determine what (if anything) the method should be declared to return. Once you have that sorted out make sure the method is declared with the correct return type. If it *does* return something there should be a "return" statement, if it is void then there should not be.

So, first thing: what do you intend this method to do? In case it's not clear, the problem is with the setAge() method.

Re: Not compiling :(

Ok, I got rid of the showInfo method all together and put it in main (Should've done that in the first place) and of course, I still get an error, but this time it has something to do with the variable.