INVENTORYPROGRAMPART4 - To change this template choose...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inventory.program.part.pkg4; import java.awt.event.*; import javax.swing.*; /** * * @author janaya */ public final class INVENTORYPROGRAMPART4 extends JFrame { private Inventory i; private JTextArea txt; private int view = 0; /** * @param args the command line arguments */ public static void main(String[] args) { INVENTORYPROGRAMPART4 gui = new INVENTORYPROGRAMPART4(); gui.pack(); gui.setVisible(true); } // view DVD public void showDVD() { txt.setText("DVD Details:\n"); txt.append(i.get(view) + "\n"); // total val txt.append(String.format("\nTotal value = $%.2f", i.totalValue())); } public INVENTORYPROGRAMPART4() { super("DVD"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // quit when closed // create 3 products ExtendedDVD p1 = new ExtendedDVD(1, "Tyler Perry's I Can Do Bad All By Myself", 3, 14.99, "24 hours"); ExtendedDVD p2 = new ExtendedDVD(2, "Shottas", 5, 19.99, "22 hours"); ExtendedDVD p3 = new ExtendedDVD(3, "Wanted", 4, 18.99, "18 hours"); // make inventory i = new Inventory(3); i.add(p1, 0); i.add(p2, 1); i.add(p3, 2); // sort i.sort(); // output for (int k = 0; k < 3; k++) { System.out.println(i.get(k)); }
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
System.out.println(); // total val System.out.printf("Total value = $%.2f", i.totalValue());
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern