Hello, I have an assignment on Java class writing and to me the codelooks fine but I have errors. I realize it is likely something really simple to fix, but as a beginner I'm not great at spotting and then fixing the issues. If someone would be able to take a look and walk me through how to fix it, that would be wonderful.
#Java Class Writing
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
same with n and out. etc
where is a?
I suggest to read the errors
I was trying to write it as age = a so I could use a as a keyword
is a public?
a doesnt exist
a does not exist
keyword?
Yes, I also change a to be age = age and name =name so now there are only six errors instead of 10
can i see those logs
that won't work because of name conflicts
i would suggest going like
this.age = age
but im not sure if that really works
java newbie attempting to help someone with java should be a sitcom
that is, in fact, how you resolve name conflicts
It did!
And I agree
wow
that was just a guess:0
i had not read the code thoroughly
We actually just learned that last class for us, thank you
glad to help! you're very welcome
now i need someone to help with my project
alright imma play a game ig
Fixed. I'm down to 3 errors left m.One (Cannot find) slightly confused
Well I wrote mOne = new Monster and am trying to call mOne did I not declare it right?
Trying to ask is Monster One bigger than Monster two
so how is it should be determined?
and, more importantly, how is Java supposed to know that?
Ah, taking a guess here, but the "isBigger" isn't declared anywhere else. Is that my issue here?
have you learned methods in your class?
Code that only runs when called
It's meant to perform a specific task (but then again all code is)
but you're supposed to create methods in your class that compare the size of a monster that the method is called on, to the size of the monster that's passed as an argument
same with name
(also, dunno why you named the field age instead of size)
Fixed
Do I need to add a boolean for checking if the names are the same?
you need to make two methods that return a boolean value
if the statement above confuses you, you should re-examine your study materials, since you've said that you already learned methods
ofc!