Hello everyone I am a new to java and I am trying to get help with my inventory program. Here is the assignment ..Modify the Inventory Program by adding a button to the GUI that allows the user to move
to the first item, the previous item, the next item, and the last item in the inventory. If the
first item is displayed and the user clicks on the Previous button, the last item should
display. If the last item is displayed and the user clicks on the Next button, the first item
should display.
• Add a company logo to the GUI using Java graphics classes. I am posting the code that I have so far from inventory 4 but i cant get it to compile and run and dont know where to start to complete this portion. Here is the code

* Modify the Inventory Program to use a GUI. 
* The GUI should display the information
* one product at a time, including the item number, 
* the name of the product, the number of units in stock,
* the price of each unit, and the value of the inventory 
* of that product. In addition, the GUI should display 
* the value of the entire inventory, the additional attribute, 
* and the restocking fee. 
// Inventory4 program for DVD

import java.util.Arrays;

public class Inventory4 {

    public static void main(String[] args) {
        FeatDVD dvd= null;
        Inventory inventory = new Inventory();
        dvd = new FeatDVD(0, "Bad Boys", 5, 12.99f, "Comedy");
        dvd = new FeatDVD(1, "Color Purple", 7, 14.99f, "Drama");
        dvd = new FeatDVD(2, "Madea Family Reunion", 6, 13.99f, "Drama");
        dvd = new FeatDVD(3, "Diary of a Mad Black Woman", 3, 15.99f, "Drama");
        dvd = new FeatDVD(4, "Forest Gump", 8, 11.99f, "Comedy");
        dvd = new FeatDVD(5, "How Stella Got Her Groove Back", 2, 12.99f, "Drama");
        dvd = new FeatDVD(6, "What's love Got to do With it", 7, 15.99f, "Drama");
        dvd = new FeatDVD(7, "Purple Rain", 7, 11.99f, "Drama");

        GUI gui = new GUI(inventory); // Start the GUI

    } // end main
} // end class Inventory4

/**** Class decribes DVD while demostrating polymorphism and inheritance**/

class DVD implements Comparable

    private int dvditem;
    private String dvdtitle; 
    private int dvdstock;
    private double dvdprice;
    // Constructor  
       dvditem = 0;
       dvdtitle = "";
       dvdstock = 0;
       dvdprice = 0;

    }// end constructor
    //constructor initializes variables
    DVD(int item, String title, int stock, double price)

       this.dvditem = item;
       this.dvdtitle = title;
       this.dvdstock = stock;
       this.dvdprice = price; 
    private void setTitle( String title )
        this.dvdtitle = title;
    public String getdvdTitle() 
        return dvdtitle;
    private void setdvdItem( int item ) 
        this.dvditem = item;
    public int getdvdItem() 
        return dvditem;
    private void setdvdStock( int stock ) 
        this.dvdstock = stock;
    public int getdvdStock() 
        return dvdstock;

    private void setdvdPrice (double price ) 
        this.dvdprice = price;
    public double getdvdPrice()
        return dvdprice;

    public double getValue() 
        double value = dvdstock * dvdprice; 
        return value;
    // This method tells the sort method what is to be sorted
    public int compareTo(Object o)
        return dvdtitle.compareTo(((DVD) o).getdvdTitle());

    // This method passes the format for the string
    public String toString() 
        return String.format("Unit number:%d %12s  Units:%2d  Price: $%5.2f  Movie value: $%6.2f",
            dvditem, dvdtitle, dvdstock, dvdprice, getValue());
} // end class DVD  

/**** This is a subclass that adds 5% restocking fee and new feature***/

class FeatDVD extends DVD
     private String genres;

     // class constructor
     FeatDVD(int item, String title, int stock, float price, String genres)
          super(item, title, stock, price);
          this.genres = genres;


     public double getValue()
     {// getvalue method overrides
      // getvalue method in the superclass
          double value = 1.05F * super.getValue();
          return value;
     }// end getValue method

     public String toString()
     {//toString method overrides the superclass toString method
      //adding another fields
         return super.toString() + "Genre:" + genres;
     }// end toString method

}// end class FeatDVD

/*****class has inventory of DVDs.
* This class has methods to add and display dvds****/

class Inventory
    private DVD[] dvds;     
    private int nCount;

    // constructor
       dvds = new DVD[10];
       nCount = 0;

    public void add(DVD dvd)
       dvds[nCount] = dvd;

	public int getNcount()
		return nCount;

    // method calculates total value of inventory
    public double getTotalValue()
       double totalValue = 0;
       for (int i = 0; i < nCount; i++)
            totalValue = dvds[i].getValue();
       return totalValue;
    } // end getTotalValue

    public DVD getDVD(int n) //use in GUI
    {// protects n and keep in range
       if (n<0)
           n = 0;
       else if (n >= nCount)
           n = nCount - 1;
       return dvds[n];
    // sorts the DVDs
    private void sort()
        Arrays.sort(dvds, 0, nCount);
    }// end sort method

    public void display()
		System.out.println("\nThe inventory contains " + nCount + "DVDs\n");
		for (int i = 0; i < nCount; i++)
			System.out.printf("%d: %s\n", i, dvds[i]);	
		System.out.printf("\nTotal value of the inventory is $%.2f\n", getTotalValue());
    } // end display method

} // end class Inventory
* GUI.java is the graphical part of the program
* for the Inventory part 4 program.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

// GUI class creates and maintains the GUI
public class GUI extends JFrame
        private Inventory inventory;                  // create new reference to object
        private JPanel jpOuterPanel;               // for outermost frame
        private JPanel jpInstructsPanel;          // the instructions
        private JPanel currentDataPanel;        // the current data header
        private JLabel jlCurrentDataTitle;         //the current data header
        private JLabel jlCurrentDataContents;  // the data contents
        private JTextField jtfValue;                 // for data acquisition
        private JButton jbNext;                      // Next button
        private int nCurrentDVDnum;             //selecting the current dvd
    GUI(Inventory inventory)
        super(" DVD Inventory Program");
        this.inventory = inventory;
        nCurrentDVDnum = 0;
        // creates outer panel
        JPanel jp;
        jpOuterPanel = new JPanel();
        jpOuterPanel.setLayout(new BoxLayout(jpOuterPanel, BoxLayout.Y_AXIS));
       // creates title line
        jpInstructsPanel = new JPanel();
        jpInstructsPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
        JLabel jLabel = new JLabel("Click on the 'Next DVD' button to see the next DVD");
        // creates current data line
        jp = new JPanel();
        jp.setLayout(new FlowLayout(FlowLayout.CENTER));
        jlCurrentDataTitle = new JLabel("" + inventory.getDVD(nCurrentDVDnum));
        // creates the data contents display line
        jp = new JPanel();
        jp.setLayout(new FlowLayout(FlowLayout.CENTER));
        jlCurrentDataContents = new JLabel("This DVD collection contains " + 
                                            inventory.getNcount() + " DVDs");
        //create text field for data acquisition
        jp = new JPanel();
        jp.add(new JLabel("Value of DVD collection:"));
        jp.setLayout(new FlowLayout(FlowLayout.CENTER));
        jtfValue = new JTextField(4);
        jtfValue.setText("$" + inventory.getTotalValue());
        updateFields();                // updates field after next button

        // set up and add the next button
        jp = new JPanel();
        jp.setLayout(new FlowLayout(FlowLayout.CENTER));
        jbNext = new JButton("Next DVD");
        jbNext.addActionListener(new NextButtonHandler());
        // quit application when window is closed
        setBounds(200, 200, 600, 300); // set frame location and size
        // set up the outer panel, turn it on.
    } // end GUI constructor
    private void updateFields() // updates info on the current DVD
        jlCurrentDataTitle.setText((nCurrentDVDnum+1) + ": " + inventory.getDVD(nCurrentDVDnum));
    } // end updateFields method

    // inner class to handle the next button
    class NextButtonHandler implements ActionListener 
        public void actionPerformed(ActionEvent event) 
        {    // sequences through the inventory
            if (nCurrentDVDnum < inventory.getNcount())
        } // end method
   }// end inner class
}// end class GUI

Post the errors that you are receiving and what problem you are having with it. You can't expect others to read the entire code line by line and debug it for you.

Also, please use the search feature in this forum for "inventory program" and see what help you can gleam from those threads. We have helped a few people with this exact assignment series recently and there are many posts.

we're not here to do your homework for you, and we're not going to go through hundreds of lines of code to find where your errors are located.

If you are getting compiler errors (which you should as you say it doesn't compile) solve those.
If you can't for whatever reason, post the error and relevant parts of the code only and maybe someone can help you.

Same with other problems, we're NOT going to do it all for you.

I am one of the people helped through this recently.
Search on my name, there should be more than enough detail in those posts to answer any question for this assignment.
I am pretty sure I asked them all! :o)


I will do that now and see what I can find. I have to get this one done before I can start on part 6.

This article has been dead for over six months. Start a new discussion instead.