title: Casting 2 separate methods in a Subclass
body: <p>So I basically have 2 methods I want to run, but I want one JButton I've made to do them both.</p>
  
  <p>I basically have a GUI. I have a Mobile, MP3 and Gadget Class. The one I have trouble is a Shop for the Gadget, where the GUI is made. They contain buttons.</p>
  
  <p>I want to run a method to make a call, but I'm not sure how to. I keep getting a Cast error. I also have to insert '0' in the line, as my method requires an int. Is there a way to allow it to take the duration from my GUI text box called 'Duration'?</p>
  
  <p>So my code for the Shop is here:</p>
  
  <pre><code> public void makeCall() 
  
  {
      int index = 0;
      Gadget Gadgets = GadgetList.get(index);
      if (index!= -1)
  {
      Mobile mobile = (Mobile) GadgetList.get(index);
      mobile.makePhoneCall();  
      mobile.insertDuration(0);
  }
  else if(Gadgets instanceof Mobile)
  {
      Mobile mobile = (Mobile) Gadgets;
  }
  else
  {
      System.out.println("This not a mobile phone");
  }
  
  }
  </code></pre>
  
  <p>My Mobile Phone class has this method I want to run:</p>
  
  <pre><code>public void makePhoneCall()
  {
      if(credit == 0)
      System.out.println("Insert more than 0 credit to make a phone call!");
  else {
      if(credit &gt;= duration) {
      System.out.println("The phone number " + number + " has been dialed and is being called for " + duration + " minutes");
      credit = credit - duration;
      duration = 0;
  }
  else {
      if(credit &lt; duration)
      System.out.println("You do not have enough credit to make a phone call! Your credit is " + credit + " pounds");
  }
  </code></pre>
  
  <p>Help with this will allow me to understand the concept of the rest of the work! Many thanks to any help I get.</p>