Nicole Anon wrote:I can't figure out what the compilation issues are. The only things we've used are notepad and command line. I know that it said there were errors, but I couldn't understand most of them.
Then
you should have stopped right there and talked to your tutor (or maybe another classmate) before you wrote another line of code.
One thing that most of us here would agree on:
Beginners don't compile often enough.
My rules of thumb, for the next time you have to do this:
Compile roughly every ten lines you write (you have 68 in your Chair class alone).Compile every time you finish writing a method or constructor, or something significant.And those are ANDed, not ORed.
The Java compiler is NOT forgiving, and it doesn't always do what we think it will. For example: simply missing out a brace ({ or }), or a semicolon (;), or putting it in the wrong place, can generate
many errors for the same line. It is also case-sensitive, and NOT clever, so if you write '
hasback' somewhere instead of '
hasBack', it will tell you it doesn't recognise it.
So, when you write classes, do it slowly, and compile them
many times.
Taking your
Chair class, I would probably have done something like this:
1. Written the declaration, viz:
and
compiled it. And by compiling, I mean
compiling and changing until there are no more errors left.
2. Added the fields viz:
and compiled it
again.
2. Added a constructor:
and compiled it
again. And at this point I would get TWO errors at Line 11:
"The method setHeight(double) is undefined for the type" - Because I haven't defined setHeight() yet."Syntax error on token "double", delete this token" - Because the call is wrong. You don't include the type of an argument when you call a method.
But now I only have
two errors to deal with, not 20.
3. So, I remove that 'double' from Line 11,
and compile it again (do you see a
pattern here?

); and now I should only have 1 error left.
4. So now I write the
setHeight() method, so I can get rid of that last error. And I compile
again...
And so on, and so on.
Do you see the point? By writing tiny amounts of code and compiling at every stage, you can correct errors
immediately.
You also don't get overwhelmed by great mountains of errors that you don't understand.
HIH
Winston