title: How do I override a method in a subclass?
body: <p>I have an inventory program written to include an array and a method to calculate total cost for all inventory items entered. I now have to include a subclass that overrides the original to include "one unique feature". I created a new file named ItemDetails to set up for the subclasses of the original Item. I need to include one unique feature and calculate the value of the inventory and calculate a 5% restocking fee in this subclass. Do I just transfer some of the relevant lines into the other class? Or do I write some code twice? I don't know what to do next. Any help is useful. Thanks. This is what I have so far:</p>
  
  <pre><code>package inventory3;
  
  public class ItemDetails extends Items
  {
  public static void override()
      {
      private String Name;
      private double pNumber, Units, Price;
  
  public ItemDetails()
          {
          }
      }
  }
  </code></pre>
  
  <p>This is the Item class file that it is supposed to override:</p>
  
  <pre><code>package inventory3;
  
  import java.lang.Comparable;                
  
      public class Items implements Comparable
  {
         private String Name;
         private double pNumber, Units, Price;
  
  public Items()
      {
  Name = "";
  pNumber = 0.0;
  Units = 0.0;
  Price = 0.0;
      }
  
  public int compareTo(Object item)
      {
  
    Items tmp = (Items) item;
  
  
      return this.getName().compareTo(tmp.getName());
      } 
  
  
  public Items(String productName, double productNumber, double unitsInStock, double unitPrice)
      {
      Name = productName;
      pNumber = productNumber;
      Units = unitsInStock;
      Price = unitPrice;
      }
      //setter methods
  public void setName(String n)
      {
      Name = n;
      }
  
  public void setpNumber(double no)
      {
      pNumber = no;
      }
  
  public void setUnits(double u)
      {
      Units = u;
      }
  
  public void setPrice(double p)
      {
      Price = p;
      }
  
  //getter methods
  public String getName()
      {
  return Name;
      }
  
  public double getpNumber()
      {
  return pNumber;
      }
  
  public double getUnits()
      {
  return Units;
      }
  
  public double getPrice()
      {
  return Price;
      }
  
  public double calculateTotalPrice()
      {
      return (Units * Price);
      }
  
  public static double getCombinedCost(Items[] item)          
      {
      double combined = 0;        
  
      for(int i =0; i &lt; item.length; ++i)
          {
          combined = combined + item[i].calculateTotalPrice();        
  
          } 
      return combined;
      }
  
  }
  </code></pre>