| | |
Inventory part 6
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
Hello,
I am trying to figure out how to correct my errors. I am new at this and this is due today. The actual assignment is ....
Modify the Inventory Program to include an Add button, a Delete button, and a Modify
button on the GUI. These buttons should allow the user to perform the corresponding
actions on the item name, the number of units in stock, and the price of each unit. An
item added to the inventory should have an item number one more than the previous last
item.
• Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
• Use exception handling to create the directory and file if necessary.
• Add a search button to the GUI that allows the user to search for an item in the inventory
by the product name. If the product is not found, the GUI should display an appropriate
message. If the product is found, the GUI should display that product’s information in the
GUI.
Here are my errors
C:\IT315\Inventory6\Inventory6.java:42: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
^
C:\IT315\Inventory6\Inventory6.java:42: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
Here is my code
I am trying to figure out how to correct my errors. I am new at this and this is due today. The actual assignment is ....
Modify the Inventory Program to include an Add button, a Delete button, and a Modify
button on the GUI. These buttons should allow the user to perform the corresponding
actions on the item name, the number of units in stock, and the price of each unit. An
item added to the inventory should have an item number one more than the previous last
item.
• Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
• Use exception handling to create the directory and file if necessary.
• Add a search button to the GUI that allows the user to search for an item in the inventory
by the product name. If the product is not found, the GUI should display an appropriate
message. If the product is found, the GUI should display that product’s information in the
GUI.
Here are my errors
C:\IT315\Inventory6\Inventory6.java:42: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
^
C:\IT315\Inventory6\Inventory6.java:42: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
Here is my code
Java Syntax (Toggle Plain Text)
import java.util.*; // using java libraries public class Inventory6 { public static void main(String[] args) { FeatDVD dvd; Inventory inventory = new Inventory(); dvd = new FeatDVD(0, "Bad Boys", 5, 12.99, "Comedy"); inventory.add(dvd); dvd = new FeatDVD(1, "Color Purple", 7, 14.99, "Drama"); inventory.add(dvd); dvd = new FeatDVD(2, "Madea Family Reunion", 6, 13.99, "Drama"); inventory.add(dvd); dvd = new FeatDVD(3, "Diary of a Mad Black Woman", 3, 15.99, "Drama"); inventory.add(dvd); dvd = new FeatDVD(4, "Forest Gump", 8, 11.99, "Comedy"); inventory.add(dvd); dvd = new FeatDVD(5, "How Stella Got Her Groove Back", 2, 12.99, "Drama"); inventory.add(dvd); dvd = new FeatDVD(6, "What's love Got to do With it", 7, 15.99, "Drama"); inventory.add(dvd); dvd = new FeatDVD(7, "Purple Rain", 7, 11.99, "Drama"); inventory.add(dvd); inventory.display(); GUI gui = new GUI(inventory); // Start the GUI OutputDVD output = new OutputDVD(inventory); } // end main } // end class Inventory6 /**** 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 DVD() { 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 genres***/ class FeatDVD extends DVD { private String genres; // class constructor FeatDVD(int item, String title, int stock, double price, String genres) { super(item, title, stock, price); this.genres = genres; } public String getGenres() { return 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 Inventory() { dvds = new DVD[8]; nCount = 0; } public int getNcount() { return nCount; } // method adds DVD to inventory public void add(DVD dvd) { dvds[nCount] = dvd; ++nCount; sort(); } public void delete(int n) { if (nCount > 0) { dvds[n] = dvds[nCount-1]; --nCount; sort(); } } public int search(String seek) { int n = -1 for (int i = 0; i < nCount; i++) { if (seek.equalsIgnoreCase(dvds[i].getdvdTitle())) { n = i; break; } } return n; } public FeatDVD getFeatDVD(int n) { return (FeatDVD) dvds[n]; } // 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 (n >= 0) ? dvds[n] : null; } // sorts the DVDs private void sort() { if (nCount > 0) Arrays.sort(dvds, 0, nCount); }// end sort method public void display() { for (int i = 0; i < nCount; i++) System.out.printf("%2d: %s\n", i, getFeatDVD(i)); } } // end class Inventory
Java Syntax (Toggle Plain Text)
GUI gui = new GUI(inventory); // Start the GUI
Last edited by peter_budo; Oct 8th, 2007 at 12:09 pm.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Inventory part 5 (Java)
- GUI buttons Inventory Part 5 (Java)
- logical consistency??? (Visual Basic 4 / 5 / 6)
Other Threads in the Java Forum
- Previous Thread: Strings in java
- Next Thread: Inventory program part 5 help
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component converter database developmenthelp eclipse error fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html ide image input int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






