I'm trying to do code here that creates the instance of a class to be used in the driver. But i'm having issues with cannot be applied to given type and cannot find symbol. Driver, and class files are below.
What do these errors actually mean and, how would I go about fixing them without using inheritance(extended reference)?
Another mistake you are making, which will cause you no end of problems in future, is not formatting your code correctly. Look at our suggestions. Not indenting and not leaving spaces between successive methods will confuse you once you start needing >' 1 level of indentation, and will hide all sorts of potential errors from you. Another thing is that the long comments make the code difficult to read here, particularly for people who are reading on a screen only 3″ wide. Avoid comments like that on line 8 because they don't tell you anything that isn't obvious already.
Your comment on line 6 isn't quite accurate.
Don't go to all the trouble of choosing good names for your fields and then obscure them by using poor names for method parameters. Don't use w: use width. This is how it is done. Don't change the structuree of the method, or you can get different errors at runtime:-
I see the reason for "cannot find symbol" is because of the "W" instead of the "w" which was syntax err. This has been fixed. Editor used also doesn't have an auto-layout option but indenting methods by 3-4 spaces should work. I'll try to keep the comments shorter to 8 words so they don't expand on the line or above the method in a block if longer.
Question about constructors. Normally, constructors can't be left without any methods inside or produces err if there are variables passed in its arguments. If a constructor is passed in another class, the arguements must be the same as in the original constructor or "formal paramaeters not same as arguments" occur?
Emily Jason wrote:I'll try to keep the comments shorter to 8 words so they don't expand on the line or above the method in a block if longer.
While you're learning, I guess it's ok to put comments in your code to remind you of what you were thinking when you were writing it. However, comments like this:
are actually worse than worthless. They are redundant and only create visual clutter in the code. Avoid comments that explain what and how. Good comments explain why something was done the way it was. Otherwise, let the code speak for itself by using self-documenting names, names that convey their intent well. For example, instead of just w, use the full word that expresses what that variable represents, like width.
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad: