title: How to make an ArrayList of objects in Java with the ability to access their values
body: <p>so I'm working on a game in Java, and I'm a little confussed on how I should go about something. It's a Trading Card Game, kinda like Magic, and so for classes so far I have</p>
  
  <ul>
  <li>GameDriver </li>
  <li>Cards</li>
  <li>WolfCard</li>
  <li>TheLarionCard</li>
  </ul>
  
  <p>It is my hope that I'll be able to have atleast 50 different types of card, each of which in their own class, so a little side question is, is this the best way? As for my problem:</p>
  
  <p>I have the following code inside my GameDriver class:</p>
  
  <pre><code>ArrayList&lt;Cards&gt;  playerHand = new ArrayList&lt;Cards&gt;();
  playerHand.add(new WolfCard());
  playerHand.add(new TheLarionCard());
  System.out.println(((Cards)playerHand.get(1)));
  </code></pre>
  
  <p>Each card extends Cards, and Cards extend GameDriver, The code above will print out something like:</p>
  
  <pre><code>TheLarionCard[panel0,0,0,0x0,invalid,layout=java.awt.FlowLayout]
  </code></pre>
  
  <p>But now, if I want to grab the health of say TheLarionCard, I thought I could just add .health to the last line like:</p>
  
  <pre><code>System.out.println(((Cards)playerHand.get(1).health));
  </code></pre>
  
  <p>But obviously I can't, what am I doing wrong here?</p>
  
  <p>Any help is great! Thank you!</p>