Answer the question
In order to leave comments, you need to log in
Is it possible to pass constants to the class constructor?
I want to pass a named constant to the class constructor
We have a class
package Bigshot.Characters;
public class CharacterCreationThree extends Thread{
MyCharacters[] array;
public enum Character{
PlayerHero, Enemy
}
public void run(){
//* MyCharacters[] array = new MyCharacters[complexity*5];
for(int count=0; count<array.length;count++){
System.out.println(count);
<b> array[count] = new MyCharacters(Character.Enemy);</b>
System.out.println("bot!");
}
}
}
package Bigshot.Characters;
public class MyCharacters{
Character CharacterType;//тип персонажа
public MyCharacters(Character CharacterType){
this.CharacterType = Character.CharacterType;
}
public void demonstrationOfHero(){
System.out.println("Character created!");
}
}
Answer the question
In order to leave comments, you need to log in
public class MyCharacters {
Character characterType;
public MyCharacters(Character characterType) {
this.characterType = characterType;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question