I feel as if I have gone over this code until my eyes are bleeding. I am missing something, and I cannot seem to locate my problem. I am supposed to use an array to store my items, my output should display my items one at a time, and should also display the value of the entire inventory. I have managed to eliminate all of my compiler errors, but my modifications are not showing in the output. Any assistance is greatly appreciated. Thank you!

// This Inventory program is an application that is designed to store and maintain a
// media collection. Inventory houses an array of DVDs, along with attributes of those DVDs.
// These attributes are, item number, item title, stock available, item price, and total value
// of each. Inventory information is then displayed for the user.

public class Invent2 // declare class inventory, which houses arrays
{

   public static void main(String args [])
   {
      DVD dvd;


      // declare and initializes array elements. declare structure of attributes for constructor.
      dvd = new DVD(1, "Pulp Fiction", 8, 12.99);
      System.out.println(dvd);

      dvd = new DVD(2, "Resevoir Dogs", 9, 12.99);
      System.out.println(dvd);

      dvd = new DVD(3, "Four Rooms", 4, 10.99);
      System.out.println(dvd);

      dvd = new DVD(4, "Kill Bill Vol. One", 5, 15.99);
      System.out.println(dvd);

      dvd = new DVD(5, "Kill Bill Vol. Two", 5, 17.99);
      System.out.println(dvd);

      dvd = new DVD(6, "Drugstore Cowboy", 2, 10.99);
      System.out.println(dvd);

      dvd = new DVD(7, "Tool - Live Aenima", 4, 19.99);
      System.out.println(dvd);

      dvd = new DVD(8, "How The West Was Won", 6, 23.95);
      System.out.println(dvd);

      dvd = new DVD(9, "Concert for Antigua", 9, 20.00);
      System.out.println(dvd);

      dvd = new DVD(10, "Delta Blues: E-chord", 2, 24.99);
      System.out.println(dvd);

   } //end main

} // end class Inventory2


class DVD // declare clas DVD
{

   private int dvdItem; // declare variables
   private String dvdTitle;
   private int dvdStock;
   private double dvdPrice;

   public DVD(int item, String title, int stock, double price) // declare constructor of four arguments
   {

      dvdItem = item; // initialize constructor arguments
      dvdTitle = title;
      dvdStock = stock;
      dvdPrice = price;

   } //end four-argument constructor

   // set DVD Item
   public void setDvdItem(int item)
   {

      dvdItem = item;

   } //end method set Dvd Item

   //return DVD Item
   public int getDvdItem()
   {

      return dvdItem;

   } //end method get Dvd Item

   //set DVD Title
   public void setDvdTitle(String title)
   {

      dvdTitle = title;

   } //end method set Dvd Title

   //return Dvd Title
   public String getDvdTitle()
   {

      return dvdTitle;

   } //end method get Dvd Title

   public void setDvdStock(int stock)
   {

      dvdStock = stock;

   } //end method set Dvd Stock

   //return dvd Stock
   public int getDvdStock()
   {

     return dvdStock;

   } //end method get Dvd Stock

   public void setDvdPrice(double price)
   {

     dvdPrice = price;

   } //end method setdvdPrice

   //return DVD Price
   public double getDvdPrice()
   {

     return dvdPrice;

   } //end method get Dvd Price

   //calculate inventory value
   public double value()
   {

      return dvdPrice * dvdStock;

   } //end method value

   public String toString()
   {

      return String.format("item=%3d title=%-20s units=%d price=%.2f value=%.2f",
      dvdItem, dvdTitle, dvdStock, dvdPrice, value());

   }

} //end class DVD

class Inventory
{
	DVD discs[] = new DVD[50];

	public void addToInventory( DVD discs ) // add to inventory
	{

     }

     public double getInventoryValue() // get total value of inventory
     {
         Inventory myInventory = new Inventory();
         myInventory.addToInventory( new DVD(1, "The Wall", 9, 9.95));
		 // print out total inventory value
         System.out.println( "Total value of the inventory is: " + myInventory.getInventoryValue());
         return myInventory.getInventoryValue();
  }
}

Another student in your class posted on this forum not too long ago. At least I'm assuming that's the case, since you guys basically have the same exact program other than the movie names. Anyway, your problem is that you are overwriting your dvd in the Invent2 class.

edit: Nevermind. That was you. I can't really improve the advice that I gave you originally, but you did not follow it. To do this program, you should only need two classes: the class where you create the DVDs, and the DVD class. I already told you how to create a DVD and put it into the array:

public class DVD{
DVD[] dvds = new DVD[10];

public static void main(String[] args){
DVD dvd = new DVD(whatever);
dvds[0] = dvd;
DVD dvd2 = new DVD(aDifferentDVD);
dvds[1] = dvd2;
}

}

Okay, at least I'm not the only goob stuck on this! =) Thank you for the help BestJew! Have a great night.

Thanks, I'll change it back to the format that you helped me with before and try to go from there. What I don't understand is that everything in class Invent2 is displaying fine the way that I have it written now (perhaps changing the code to follow your advice will allow the new changes to display). Thanks, I really do appreciate you taking time to help me.

Every time you set dvd = new DVD(), you are overwriting what you previously put into dvd. Again, consider this example:

DVD[] allMovies = new DVD[10]; -- This statement creates an array big enough to hold 10 DVDs.

DVD movie = new DVD(lionKing); -- This statement creates a new variable of type DVD called "movie". It then puts the DVD lion king into the movie variable. (What it actually does is a bit more complex, but this is what it amounts to)

movie = new DVD(granTorino); -- Now we just put gran torino into the movie variable. So where is lion king now? Nowhere.

From where you're currently at, there really isn't much need to erase everything. You just need to put an array in the Invent2 class, then add each dvd to the array after you create it.

Invent2{

//declare an array of DVDs here

main method(){
dvd = new DVD(1, "Pulp Fiction", 8, 12.99);
array[0] = dvd;
System.out.println(dvd);

dvd = new DVD(2, "Resevoir Dogs", 9, 12.99);
array[1] = dvd;
System.out.println(dvd);
}

}

The reason I said you didn't need three classes is because the Inventory class isn't really necessary. You can take all the code you were going to put in Inventory and put it in Invent2 instead. Since all the Inventory class does is contain an array that holds your DVDs, it makes more sense to combine this with the other class.

Also, I apologize if I confused you with my multiple posts. I'm kind of tired and at one point I briefly gave you incorrect information, although I don't think you saw this information (as it was only there for a minute or two).

The following is my complete code as of now. I am recieving a compiler error that I cannot track down. The error is at line 105:
} // end class Inventory2. The error message is the " class, interface, or enum expected". I do not find any open or missing braces, does anyone else see the problem? Thanks.

import java.text.DecimalFormat;

public class InventoryPart2
{
   // set up an array
   int inventorySize = 50;
   public DVD items[] = new DVD[50];

   //set the formatter to format values into currency
   DecimalFormat formatter = new DecimalFormat( "$##,###.00" );

   InventoryPart2 ProductList = new InventoryPart2();

   // adds a product to the array of products at the first available slot
   public void addProduct( DVD item )
   {
      for ( int i = 0; i < inventorySize; i++ )
      {
         if ( items[i] == null )
         {
            items[i] = item;
            return;
         } // end if
      } // end for
   } // end addProduct

   public void main( String args[] )
   {
      DVD[] DVD =items;

      dvd = new DVD(1, "Pulp Fiction", 8, 12.99);
      DVD [0] = dvd;
      System.out.println(dvd);

      dvd = new DVD(2, "Resevoir Dogs", 9, 12.99);
      DVD[1] = dvd;
      System.out.println(dvd);

      dvd = new DVD(3, "Four Rooms", 4, 10.99);
      DVD[2] = dvd;
      System.out.println(dvd);

      dvd = new DVD(4, "Kill Bill Vol. One", 5, 15.99);
      DVD[3] = dvd;
      System.out.println(dvd);

      dvd = new DVD(5, "Kill Bill Vol. Two", 5, 17.99);
      DVD[4] = dvd;
      System.out.println(dvd);

      dvd = new DVD(6, "Drugstore Cowboy", 2, 10.99);
      DVD[5] = dvd;
      System.out.println(dvd);

      dvd = new DVD(7, "Tool - Live Aenima", 4, 19.99);
      DVD[6] = dvd;
      System.out.println(dvd);

      dvd = new DVD(8, "How The West Was Won", 6, 23.95);
      DVD[7] = dvd;
      System.out.println(dvd);

      dvd = new DVD(9, "Concert for Antigua", 9, 20.00);
      DVD[8] = dvd;
      System.out.println(dvd);

      dvd = new DVD(10, "Delta Blues: E-chord", 2, 24.99);
      DVD[9] = dvd;
      System.out.println(dvd);
   }

   public double getTotalInvValue;
   {
      double sumOfInventory = 0.0;

      for ( DVD item : items )
      {
          if ( item != null )
          {
              sumOfInventory += item.getItemValue();
           } // end if
            }
            return sumOfInventory;
         }

         public void printInventory();
         {
            System.out.println( "Printing all items in the inventory...\n");

            boolean hasItems = false;

            for ( DVD items : items )
            {
               if ( item != null )
               {
                  hasItems = true;
                  System.out.println( item.toString() + "Quantity:" + item.getQuantityOnHand() +
                          "Value of Stock:" + formatter.format( item.getItemValue()) );
               }
            }
         }

   } //end main



class DVD // declare clas DVD
{

   private int dvdItem; // declare variables
   private String dvdTitle;
   private int dvdStock;
   private double dvdPrice;

   public DVD(int item, String title, int stock, double price) // declare constructor of four arguments
   {

      dvdItem = item; // initialize constructor arguments
      dvdTitle = title;
      dvdStock = stock;
      dvdPrice = price;

   } //end four-argument constructor

   // set DVD Item
   public void setDvdItem(int item)
   {

      dvdItem = item;

   } //end method set Dvd Item

   //return DVD Item
   public int getDvdItem()
   {

      return dvdItem;

   } //end method get Dvd Item

   //set DVD Title
   public void setDvdTitle(String title)
   {

      dvdTitle = title;

   } //end method set Dvd Title

   //return Dvd Title
   public String getDvdTitle()
   {

      return dvdTitle;

   } //end method get Dvd Title

   public void setDvdStock(int stock)
   {

      dvdStock = stock;

   } //end method set Dvd Stock

   //return dvd Stock
   public int getDvdStock()
   {

     return dvdStock;

   } //end method get Dvd Stock

   public void setDvdPrice(double price)
   {

     dvdPrice = price;

   } //end method setdvdPrice

   //return DVD Price
   public double getDvdPrice()
   {

     return dvdPrice;

   } //end method get Dvd Price

   //calculate inventory value
   public double value()
   {

      return dvdPrice * dvdStock;

   } //end method value

   public String toString()
   {

      return String.format("item=%3d title=%-20s units=%d price=%.2f value=%.2f",
      dvdItem, dvdTitle, dvdStock, dvdPrice, value());
   }
   public double getInventoryValue() // get total value of inventory
	       {
	           InventoryPart2 myInventory = new InventoryPart2();

	           myInventory.addToInventoryPart2( new DVD(11, "The Wall", 9, 9.95));

	  		 // print out total inventory value
	           System.out.println( "Total value of the inventory is: " + myInventory.getInventoryValue());
               return myInventory.getDVDValue();
	       }

} //end class DVD

You still have a lot of errors.

  1. The "main" method should be declared as public static void main(String[] args), and this declaration should never be changed to something else. The reason is because it is just a standard that main is the method which will run when you start the program, so changing it's usual declaration is confusing.

  2. You said DVD[] DVD = items, which might work, but does not make sense. Delete it, and instead of saying DVD[0] = whatever, say items[0] = whatever.

Change those couple things and then tell me what errors you are getting. And re-post your code using the Java code tags. To do this, just click everything you normally would, but then when it says (CODE) change it to (CODE=Java) (only for the first CODE tag)

I changed main back to public static void(String[] args), deleted
DVD[] DVD = items, and changed the instances of DVD[0] (DVD[1], DVD[2]...) to items[0], and I now have 45 errors. I am just freaking lost here... here is my code ( I apologize for not formatting correctly earlier).

import java.text.DecimalFormat;

public class InventoryPart2
{
   // set up an array
   int inventorySize = 50;
   public DVD items[] = new DVD[50];

   //set the formatter to format values into currency
   DecimalFormat formatter = new DecimalFormat( "$##,###.00" );

   InventoryPart2 ProductList = new InventoryPart2();

   // adds a product to the array of products at the first available slot
   public static void addProduct( DVD item )
   {
      for ( int i = 0; i < inventorySize; i++ )
      {
         if ( items[i] == null )
         {
            items[i] = item;
            return;
         } // end if
      } // end for
   } // end addProduct

   public void main( String[] args )
   {

      dvd = new DVD(1, "Pulp Fiction", 8, 12.99);
      items[0] = dvd;
      System.out.println(dvd);

      dvd = new DVD(2, "Resevoir Dogs", 9, 12.99);
      items[1] = dvd;
      System.out.println(dvd);

      dvd = new DVD(3, "Four Rooms", 4, 10.99);
      items[2] = dvd;
      System.out.println(dvd);

      dvd = new DVD(4, "Kill Bill Vol. One", 5, 15.99);
      items[3] = dvd;
      System.out.println(dvd);

      dvd = new DVD(5, "Kill Bill Vol. Two", 5, 17.99);
      items[4] = dvd;
      System.out.println(dvd);

      dvd = new DVD(6, "Drugstore Cowboy", 2, 10.99);
      items[5] = dvd;
      System.out.println(dvd);

      dvd = new DVD(7, "Tool - Live Aenima", 4, 19.99);
      items[6] = dvd;
      System.out.println(dvd);

      dvd = new DVD(8, "How The West Was Won", 6, 23.95);
      items[7] = dvd;
      System.out.println(dvd);

      dvd = new DVD(9, "Concert for Antigua", 9, 20.00);
      items[8] = dvd;
      System.out.println(dvd);

      dvd = new DVD(10, "Delta Blues: E-chord", 2, 24.99);
      items[9] = dvd;
      System.out.println(dvd);
   }

   public double getTotalInvValue;
   {
      double sumOfInventory = 0.0;

      for ( DVD item : items )
      {
          if ( item != null )
          {
              sumOfInventory += item.getItemValue();
           } // end if
            }
            return sumOfInventory;
         }

         public void printInventory();
         {
            System.out.println( "Printing all items in the inventory...\n");

            boolean hasItems = false;

            for ( DVD items : items )
            {
               if ( item != null )
               {
                  hasItems = true;
                  System.out.println( item.toString() + "Quantity:" + item.getQuantityOnHand() +
                          "Value of Stock:" + formatter.format( item.getItemValue()) );
               }
            }
         }

   } //end main



class DVD // declare clas DVD
{

   private int dvdItem; // declare variables
   private String dvdTitle;
   private int dvdStock;
   private double dvdPrice;

   public DVD(int item, String title, int stock, double price) // declare constructor of four arguments
   {

      dvdItem = item; // initialize constructor arguments
      dvdTitle = title;
      dvdStock = stock;
      dvdPrice = price;

   } //end four-argument constructor

   // set DVD Item
   public void setDvdItem(int item)
   {

      dvdItem = item;

   } //end method set Dvd Item

   //return DVD Item
   public int getDvdItem()
   {

      return dvdItem;

   } //end method get Dvd Item

   //set DVD Title
   public void setDvdTitle(String title)
   {

      dvdTitle = title;

   } //end method set Dvd Title

   //return Dvd Title
   public String getDvdTitle()
   {

      return dvdTitle;

   } //end method get Dvd Title

   public void setDvdStock(int stock)
   {

      dvdStock = stock;

   } //end method set Dvd Stock

   //return dvd Stock
   public int getDvdStock()
   {

     return dvdStock;

   } //end method get Dvd Stock

   public void setDvdPrice(double price)
   {

     dvdPrice = price;

   } //end method setdvdPrice

   //return DVD Price
   public double getDvdPrice()
   {

     return dvdPrice;

   } //end method get Dvd Price

   //calculate inventory value
   public double value()
   {

      return dvdPrice * dvdStock;

   } //end method value

   public String toString()
   {

      return String.format("item=%3d title=%-20s units=%d price=%.2f value=%.2f",
      dvdItem, dvdTitle, dvdStock, dvdPrice, value());
   }
   public double getInventoryValue() // get total value of inventory
	       {
	           InventoryPart2 myInventory = new InventoryPart2();

	           myInventory.addToInventoryPart2( new DVD(11, "The Wall", 9, 9.95));

	  		 // print out total inventory value
	           System.out.println( "Total value of the inventory is: " + myInventory.getInventoryValue());
               return myInventory.getDVDValue();
	       }

} //end class DVD

I left something out of that last code (8 errors with this code).
1.

sumOfInventory += item.getItemValue();

2.

return sumOfInventory;

3.

public void printInventory();

4.

for ( DVD items : items )

5.

if ( item != null )

6.

System.out.println( item.toString() + "Quantity:" + item.getQuantityOnHand() +
                          "Value of Stock:" + formatter.format( item.getItemValue()) );

7.

myInventory.addToInventoryPart2( new DVD(11, "The Wall", 9, 9.95));

8.

System.out.println( "Total value of the inventory is: " + myInventory.getInventoryValue());
               return myInventory.getDVDValue();
import java.text.DecimalFormat;

public class InventoryPart2
{
   // set up an array
   int inventorySize = 50;
   public DVD items[] = new DVD[50];

   //set the formatter to format values into currency
   DecimalFormat formatter = new DecimalFormat( "$##,###.00" );

   InventoryPart2 ProductList = new InventoryPart2();

   // adds a product to the array of products at the first available slot
   public void addProduct( DVD item )
   {
      for ( int i = 0; i < inventorySize; i++ )
      {
         if ( items[i] == null )
         {
            items[i] = item;
            return;
         } // end if
      } // end for
   } // end addProduct

   public void main( String[] args )
   {
      DVD dvd = new DVD(1, "Pulp Fiction", 8, 12.99);
      items[0] = dvd;
      System.out.println(dvd);

      dvd = new DVD(2, "Resevoir Dogs", 9, 12.99);
      items[1] = dvd;
      System.out.println(dvd);

      dvd = new DVD(3, "Four Rooms", 4, 10.99);
      items[2] = dvd;
      System.out.println(dvd);

      dvd = new DVD(4, "Kill Bill Vol. One", 5, 15.99);
      items[3] = dvd;
      System.out.println(dvd);

      dvd = new DVD(5, "Kill Bill Vol. Two", 5, 17.99);
      items[4] = dvd;
      System.out.println(dvd);

      dvd = new DVD(6, "Drugstore Cowboy", 2, 10.99);
      items[5] = dvd;
      System.out.println(dvd);

      dvd = new DVD(7, "Tool - Live Aenima", 4, 19.99);
      items[6] = dvd;
      System.out.println(dvd);

      dvd = new DVD(8, "How The West Was Won", 6, 23.95);
      items[7] = dvd;
      System.out.println(dvd);

      dvd = new DVD(9, "Concert for Antigua", 9, 20.00);
      items[8] = dvd;
      System.out.println(dvd);

      dvd = new DVD(10, "Delta Blues: E-chord", 2, 24.99);
      items[9] = dvd;
      System.out.println(dvd);
   }

   public double getTotalInvValue;
   {
      double sumOfInventory = 0.0;

      for ( DVD item : items )
      {
          if ( item != null )
          {
              sumOfInventory += item.getItemValue();
           } // end if
            }
            return sumOfInventory;
         }

         public void printInventory();
         {
            System.out.println( "Printing all items in the inventory...\n");

            boolean hasItems = false;

            for ( DVD items : items )
            {
               if ( item != null )
               {
                  hasItems = true;
                  System.out.println( item.toString() + "Quantity:" + item.getQuantityOnHand() +
                          "Value of Stock:" + formatter.format( item.getItemValue()) );
               }
            }
         }

   } //end main



class DVD // declare clas DVD
{

   private int dvdItem; // declare variables
   private String dvdTitle;
   private int dvdStock;
   private double dvdPrice;

   public DVD(int item, String title, int stock, double price) // declare constructor of four arguments
   {

      dvdItem = item; // initialize constructor arguments
      dvdTitle = title;
      dvdStock = stock;
      dvdPrice = price;

   } //end four-argument constructor

   // set DVD Item
   public void setDvdItem(int item)
   {

      dvdItem = item;

   } //end method set Dvd Item

   //return DVD Item
   public int getDvdItem()
   {

      return dvdItem;

   } //end method get Dvd Item

   //set DVD Title
   public void setDvdTitle(String title)
   {

      dvdTitle = title;

   } //end method set Dvd Title

   //return Dvd Title
   public String getDvdTitle()
   {

      return dvdTitle;

   } //end method get Dvd Title

   public void setDvdStock(int stock)
   {

      dvdStock = stock;

   } //end method set Dvd Stock

   //return dvd Stock
   public int getDvdStock()
   {

     return dvdStock;

   } //end method get Dvd Stock

   public void setDvdPrice(double price)
   {

     dvdPrice = price;

   } //end method setdvdPrice

   //return DVD Price
   public double getDvdPrice()
   {

     return dvdPrice;

   } //end method get Dvd Price

   //calculate inventory value
   public double value()
   {

      return dvdPrice * dvdStock;

   } //end method value

   public String toString()
   {

      return String.format("item=%3d title=%-20s units=%d price=%.2f value=%.2f",
      dvdItem, dvdTitle, dvdStock, dvdPrice, value());
   }
   public double getInventoryValue() // get total value of inventory
	       {
	           InventoryPart2 myInventory = new InventoryPart2();

	           myInventory.addToInventoryPart2( new DVD(11, "The Wall", 9, 9.95));

	  		 // print out total inventory value
	           System.out.println( "Total value of the inventory is: " + myInventory.getInventoryValue());
               return myInventory.getDVDValue();
	       }

} //end class DVD

Error 1: The DVD class does not have a method called getItemValue, hence the error. You have to write the method.

Error 2: This isn't actually an error. Once you correct the previous error, it will go away, I believe.

Thank you for the encouragement, and the help. I was so frustrated that I scrapped my original and started over from scratch. This time I referred to my text at every turn, and my code came out looking quite a bit different than before. Now it compiles and runs (it seems like I have compiled this code hundreds of times now), but one of my new additions, a 5% restocking fee is not displaying. I have been rewriting this code for over a day now, and my eyes could be the problem! I would appreciate any input on the restocking problem. Thanks!

import java.util.Scanner;

public class InventoryProgramPart3
{


     public static void main(String args[] ) // main method begins program execution
     {
          // create Scanner to obtain input from command window
          Scanner input = new Scanner( System.in );


          System.out.println( "Welcome to Inventory Program Part 3!" ); // display a welcome message

          products[] products = new products[50]; // an array of 50 products

          products[0] = new products( 1, "Resevoir Dogs", 90, 12.99);
          products[1] = new products( 2, "Pulp Fiction", 80, 12.99 );
          products[2] = new products( 3, "Four Rooms", 40, 10.99 );
          products[3] = new products( 4, "Kill Bill 1", 50, 15.99 );
          products[4] = new products( 5, "Kill Bill 2", 50, 17.99 );


          products[0].showInventory(); // display the inventories one at a time
          products[1].showInventory();
          products[2].showInventory();
          products[3].showInventory();
          products[4].showInventory();


          for ( int i = 0; i < args.length; i++ ) // sort products by name
          System.out.println( args[i] + ", " );

          double array[] = { 1169.10, 1039.20, 439.60, 799.50, 899.50 };
          double total = 0;


          for ( int counter = 0; counter < array.length; counter++) // add each element's value to total
               total += array[ counter ];
          System.out.printf( "\nTotal inventory value is: $%.2f\n", total );

          System.out.println( "\nThank you for using Inventory Program Part 3!\n" );

     } // end method main

} // end class InventoryProgramPart3

class products
{
     public int productsNumber;
     public String productsName = new String();
     public int productsUnits;
     public double productsPrice;


     public void setProductsNumber( int number ) // set products number
     {
          this.productsNumber = number;
     } // end method set products number


     public int getProductsNumber() // return products number
     {
          return productsNumber;
     } // end method get products number


     public void setProductsName( String name ) // set products name
     {
          this.productsName = name;
     } // end method set products name


     public String getProductsName() // return products name
     {
          return productsName;
     } // end method get products name


     public void setProductsUnits( int units ) // set products in stock
     {
          this.productsUnits = units;
     } // end method set products units


     public int getProductsUnits() // return products units
     {
          return productsUnits;
     } // end method get products units


     public void setProductsPrice( double price ) // set products price
     {
          this.productsPrice = price;
     } // end method set products price


     public double getProductsPrice() // return products price
     {
          return productsPrice;
     } // end method get products price


     public double getValue() // calculate products inventory value
     {
          return productsUnits * productsPrice;
     } // end method products inventory value


     products( int number, String name, int units, double price ) // four-argument constructor
     {
          productsNumber = number;
          productsName = name;
          productsUnits = units;
          productsPrice = price;
     } // end four-argument constructor


     public void showInventory() // display inventory
     {
          System.out.println(); // outputs blank line

          System.out.println( "Product Number:  "+productsNumber );
          System.out.println( "Product Name:  "+productsName );
          System.out.println( "Units in Stock:  "+productsUnits );
          System.out.printf( "Unit Price:  $%.2f", productsPrice );

          director products = new director
               ( 1, "Action", 90, 12.99, "Quentin Tarentino" );

          System.out.println( "\nDirector:  "+products.getDirector() );


          System.out.printf( "\nInventory value of "+productsName+ " is = $%.2f\n",
               getValue() ); // display the value

    } // end display inventory

} // end class products

class director extends products
{

     private String productsDirector; // holds the products director


     director( int number, String name, int units,
          double price, String director ) // five-argument constructor
     {
          super( number, name, units, price );
          productsDirector = director;
     } // end five-argument constructor


     public void setDirector( String director ) // set products director
     {
          this.productsDirector = director;
     } // end method set products director


     public String getDirector() // return products director
     {
         return productsDirector;
     } // end method get products director


   @Override
     public double getValue() // add 5% restocking fee
     {
          return super.getValue()  * .05;
     } // end method return products director


     public double getRestockingFee() // calculate restocking fee
     {
          return super.getValue() * .05;
     } //end method calculate restocking fee


   @Override
     public String toString() //return String representation of productsDirector
     {
          String formatString = "Director:  %s";
          formatString += "Restocking Fee:  $%.2f";
          formatString = String.format( formatString, productsDirector,
               super.getValue() * 0.05 );
          return( formatString + super.toString() );
     } // end toString()


   @Override
     public void showInventory() // display inventory
     {
          super.showInventory();
          System.out.println( toString() );


          System.out.printf( "\nInventory value of "+productsName+ " is = $%.2f\n",
               getRestockingFee() ); // Display value plus restocking fee

     } // end method display inventory

} // end class director

public double getRestockingFee() // calculate restocking fee
{
return super.getValue() * .05;
}

I'm personally very busy right now, so i apologize if you knew this already, but you are calling the method from your parent class when you use super.getValue() . . not the method from the class you are in. I just don't see a reason why you'd want to do that, considering you overrode the getValue method, is why I even mention it.

commented: Great explanations and help! Problem solved! +1

Hi Folks!
BestJewSinceJC has helped me solve my problem, and I would like to give him credit for that. The problem is that I can't find any way to mark this as "solved". Could someone help me out?

You can mark the thread as solved by clicking the link at the bottom of the thread that says "mark as solved". It should be a blue link underneath the very last post, next to the yellow button that says 'Reply to Thread'. Basically, it's just a way for the person who originally created the thread to acknowledge everyone who posted in it. It's also helpful because then people will know the thread is solved. If you can't find it though, or if for some reason it isn't there, don't worry about it, its no big deal. To me, its cool just to know that I was able to help someone solve their problem and learn more programming in the process

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.