+ 2
Identifier expected error
Started writing something trying to figure out the errors and learning from them https://code.sololearn.com/cD2B294qOb7X/?ref=app
7 RĂ©ponses
+ 2
not entirely sure what you want to do, but this is an example of what i think you might be wanting to do:
https://code.sololearn.com/c96nyN2UsFZ4/?ref=app
+ 9
First understand the basic of java
Becz your programee have a soo many erreors.
https://www.sololearn.com/Course/Java/?ref=app
tap on the java course and select class and object section and learn how to creat a class
+ 2
the problem in your code is youâre trying to create a Player object with parameters that havenât been defined. You need to create a constructor for the Player class. Since youâre trying to define (name, attack, defense, health) then you need to create a constructor that accepts (String, int, int, int) and assigns those values to your instance variables. Check out the bottom of my code in the player class where I created the constructor.
Well thats one of the issues anyway, youâve got a few others related to order of operations and handling classes
+ 1
Im not good at Java but you must use getter and setter methods.
https://www.w3schools.com/java/java_encapsulation.asp
0
Jake that's the main idea , yes, but I specifically want to learn the errors in order to fix them myself with time and experience.
I guessed that my program couldn't understand what is that Bulbasaur I'm referring to, so I received that error.
I'll learn from your code.
Thanks.
0
Jake
Awesome.
If i set up some constructors in a class, such as Player, I'm able to use those constructors ( or more like calling them ) in a different class. As long as I don't make that class protected or private right?
0
Yes, a class constructor will be automatically called any time you create an instance of that class. If it only has a single constructor, and it contains parameters such as (name, attack, defense, health), then you will need to define those values any time you create an instance of the class.
https://www.sololearn.com/learn/Java/2157/