title: Java game select player class
body: <p>I'm learning java by creating a game and i have :</p>
  
  <pre><code>public abstract class Char {
      private int hp;
      private int def;
      private int power;
      private int intelligence;
      privat1e int lvl;
      private int xp;
  
  public void levelUp()
  {
      lvl += 1;
      hp *= 2;
      def *= 2;
      power *= 2;
      intelligence *= 2;
  }
  
  public void basicalAttack(Char ennemy)
  {
      ennemy.hp = ennemy.hp - (power - ennemy.def);
  }
  
  public int getHp() {
      return hp;
  }
  public void setHp(int hp) {
      this.hp = hp;
  }
  public int getDef() {
      return def;
  }
  public void setDef(int def) {
      this.def = def;
  }
  public int getPower() {
      return power;
  }
  public void setPower(int power) {
      this.power = power;
  }
  public int getIntelligence() {
      return intelligence;
  }
  public void setIntelligence(int intelligence) {
      this.intelligence = intelligence;
  }
  public int getLvl() {
      return lvl;
  }
  public void setLvl(int lvl) {
      this.lvl = lvl;
  }
  public int getXp() {
      return xp;
  }
  public void setXp(int xp) {
      this.xp = xp;
  }
  
  }
  </code></pre>
  
  <p>Then i have 2 class of characters : </p>
  
  <pre><code>public class Wizard extends Char {
  
  public Wizard() {
      setLvl(1);
      setHp(400);
      setDef(150);
      setPower(20);
      setIntelligence(200);
  }
  
  public void fireBallAttack(Char ennemy)
  {
      ennemy.setHp(ennemy.getHp() - (this.getIntelligence() + 20 - ennemy.getDef()));
  }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class Warrior extends Char {
  
  public Warrior() {
      setLvl(1);
      setHp(1000);
      setDef(250);
      setPower(100);
      setIntelligence(20);
  }
  
  public void swordAttack(Char ennemy)
  {
      ennemy.setHp(ennemy.getHp() - (this.getPower() + 10 - ennemy.getDef()));
  }
  }
  </code></pre>
  
  <p>So I want my playable Character to choose a class : </p>
  
  <pre><code>public class PlayableChar extends Char {
  private String name;
  private Char playable;
  public PlayableChar(String name, String job) {
      this.setName(name);
      switch (job)
      {
          case "warrior" :
              setPlayable(new Warrior());
              break;
          case "Wizard" :
              setPlayable(new Wizard());
              break;
      }
  }
  
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  
  public Char getPlayable() {
      return playable;
  }
  public void setPlayable(Char playable) {
      this.playable = playable;
  }
  
  }
  </code></pre>
  
  <p>So I ask to the user  which class he wants to use in my main  with </p>
  
  <pre><code>    Scanner readline = new Scanner(System.in);
      String jobName = "";
      String Name = "";
      System.out.print("Your name: ");
      Name = readline.nextLine();
      jobName = readline.nextLine();
      Playable mainChar = new Playable(Name, jobName);
  </code></pre>
  
  <p>Actually it works but when I want to use a method with <code>mainChar.getPlayable().fireBallAttack(ennemy)</code> it doesn't work and I get a</p>
  
  <blockquote>
    <p>fireBall(ennemy) is undefined for the Type Char;</p>
  </blockquote>
  
  <p>Do I need to change my Warrior and Wizard classes ? or something else ? Thanks.</p>