Code:
package Inventory8;
import java.awt.event.*;
import java.awt.Window;
import javax.swing.*;
import javax.swing.JPanel;
//Stores information and retrieves information
public class DVD_Application extends JFrame {
public JTextArea txt;
public Inventory inv;
public int currentDisplay = 0;
public DVD_Application() {
super("DVD Inventory Program");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // quit if the window is closed
init();
}
}
/**
*
* @throws java.lang.UnsupportedOperationException
*/
public void ContentPanel() throws UnsupportedOperationException {
throw new UnsupportedOperationException("Not yet implemented");
}
public void init() {
//create product information
dvdExt p1 = new dvdExt(1, "Some Like It Hot", 10, 8.00, "Classics");
dvdExt p2 = new dvdExt(2, "Liar, Liar", 5, 15.00, "Comedy");
dvdExt p3 = new dvdExt(3, "300", 7, 17.00, "Action");
dvdExt p4 = new dvdExt(4, "Rambo", 5, 10.00, "Action");
}
// create inventory and iput information
inv = new Inventory();
inv.add(p1);
inv.add(p2);
inv.add(p3);
inv.add(p4);
inv.sort();
// output the information
for (int k = 0; k < inv.size(); k++) {
System.out.println("DVD Item number: " + inv.get(k).getItem());
System.out.println("DVD Title: " + inv.get(k).getName());
System.out.println("DVD Quantity in stock: " + inv.get(k).getUnits());
System.out.println("DVD Price: $" + String.format("%.2f",inv.get(k).getPrice()));
System.out.println("DVD Total Inventory Value: $" + String.format("%.2f",inv.get(k).value()));
System.out.println("Restocking Fee: $" + String.format("%.2f",inv.get(k).fee()));
System.out.println();
}
//total val
System.out.println("Total value: $" + String.format("%.2f",inv.value()));
//graphical interface
final JPanel panel = new JPanel();
txt = new JTextArea(25,40); //size of window
txt.setEditable(false);//user unable to edit
panel.add(txt);
final JPanel anotherbuttonpanel = new JPanel();
anotherbuttonpanel.setLayout(new BoxLayout(anotherbuttonpanel,BoxLayout.Y_AXIS));
final JPanel buttonpanel = new JPanel();
buttonpanel.setLayout(new BoxLayout(buttonpanel,BoxLayout.Y_AXIS));
final JButton previous = new JButton("Previous");
previous.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (currentDisplay > 0) currentDisplay--;//method to go to previous
else currentDisplay = inv.size()-1;
displayDVD();
JButton first = new JButton("First");
first.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentDisplay = 0;//method to go to beginning
displayDVD(); }
});
buttonpanel.add(previous);
JButton next = new JButton("Next");
next.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (currentDisplay < inv.size()-1) currentDisplay++; //method to go to end
else currentDisplay = 0;
displayDVD();
}
});
buttonpanel.add(next);
JButton last = new JButton("Last");
last.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentDisplay = inv.size()-1;//method to go to next item
displayDVD();
}
});
buttonpanel.add(last);
// make the object
dvdExt dvd = new dvdExt(inv.highestNumber()+1, name, units, price, Genre);
// add object to inv
inv.addNewExtendedDVD(dvd);
currentDisplay = inv.size()-1;
displayDVD();
}
});
buttonpanel.add(new Logo());
panel.add(buttonpanel);
panel.add(anotherbuttonpanel);
displayDVD();
}
// display
public void displayDVD() {
txt.setText("DVD Details:\n");
txt.append("DVD Item number: " + inv.get(currentDisplay).getItem() + "\n");
txt.append("DVD Title: " + inv.get(currentDisplay).getName() + "\n");
txt.append("DVD Quantity in Stock: " + inv.get(currentDisplay).getUnits() + "\n");
txt.append("DVD Price: $" + String.format("%.2f",inv.get(currentDisplay).getPrice()) + "\n");
txt.append("DVD Total value: $" + String.format("%.2f",inv.get(currentDisplay).value()) + "\n");
txt.append("Restocking Fee: $" + String.format("%.2f",inv.get(currentDisplay).fee()) + "\n");
txt.append("Total value: $" + String.format("%.2f",inv.value()));
}
/**
*
* @return
*/
public Object getContentPanel() {
return this.getContentPanel();
public DVD_Application gui = new DVD_Application();
gui.pack();
gui.setVisible(true);
}
// I have this final file that is saying I don't have a main method. I have been working all night on my exchange server. I know I can't see the forest for the trees. I am exhausted. When I put the public void string args in I get the "class, interface or enumerator exptected.