class - Java "VariableDeclaratorId expected after this token" -
i'm working on little project fun, that's little combat emulator. i'm trying use class similar struct in c++, in using create object (in case, character or "entity", class called). i'm getting error in title when attempting call integer in said class main function.
class entity{ public int health; public int accuracy; public int power; public int defense; } and
public class tutorial { static random rnd = new random(); entity player; player.health = 100; // issue on health part player.accuracy = 19; // issue on accuracy part player.power = 15; // issue on power part player.defense = 18; // think now... i've been looking around while find explanation, there's none find explain nature of error possible fixes situation. if those, wonderful.
the compiler expecting variable declaration on line
player.health = 100; but finding assignment instead. statements
entity player = new entity(); player.health = 100; player.accuracy = 19; player.power = 15; player.defense = 18; should in code block such method or constructor rather class block
Comments
Post a Comment