java - Writing a constructor, takes an enum argument from a different class -
i trying program ai game , wanna able set different modes players.
here enum in type.java:
public enum type { human,random,minimax }
and here constructor in player.java set type of player:
public player(string name, type e ) { this.name = name; this.type = e; }
now eclipse says "type cannot resolved or not field." should do? both files in same package.
now eclipse says "type cannot resolved or not field."
that's telling problem has type
in line:
this.type = e; // ^---- 1
declare field in player
if haven't already:
private type type;
...and make sure you're using field's name in constructor:
this.type = e;
note i've used lower case field name. overwhelming convention in java, , matches did field name
.
Comments
Post a Comment