Results 21 to 27 of 27
Thread: Inventory Part 4 assistance
- 11-05-2010, 03:52 PM #21
Member
- Join Date
- Oct 2010
- Posts
- 68
- Rep Power
- 0
- 11-05-2010, 03:54 PM #22
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
It depends on what you want to do. Without knowing what you want to do, or why there is a GUI attached, its really hard to say.
- 11-05-2010, 04:15 PM #23
Member
- Join Date
- Oct 2010
- Posts
- 68
- Rep Power
- 0
- 11-05-2010, 04:38 PM #24
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
So the GUI will only be responsible for displaying whats currently in an Inventory object? Are you eventually going to want it to be able to add/remove DVD/items from the Inventory?
For right now I guess you can create a JFrame that accepts the array of DVD's to display. Try making just the JFrame with the GUI Components set up so they display how you want it to look.
Inside whatever main method you choose to use, you'd then create the instance of the GUI and just set the DVD's to display to it. You could use your current main method.
Java Code:public static void main(String args []) { BlurayDVD[] blu = new BlurayDVD[6]; blu[0] = new BlurayDVD("Independence Day", 6, 5.23, 1, "Standard DVD"); System.out.println(blu); blu[1] = new BlurayDVD("X-Men", 8, 4.73, 2, "Standard DVD"); System.out.println(blu); blu[2] = new BlurayDVD("Jurassic Park", 3, 6.01, 3, "Standard DVD"); System.out.println(blu); blu[3] = new BlurayDVD ("My Cousin Vinny", 4, 3.15, 4, "Standard DVD"); System.out.println(blu); blu[4] = new BlurayDVD ("The Mist", 3, 6.58, 5, "BluRay DVD"); System.out.println(blu); blu[5] = new BlurayDVD ("Independence DaySE", 4, 7.81, 6, "BluRay DVD"); System.out.println(blu); double total = 0; ArrayList<BlurayDVD> bluList = new ArrayList<BlurayDVD>(); BlurayDVD b0 = new BlurayDVD ("The Mist", 3, 6.58, 5, "Standard DVD"); BlurayDVD b1 = new BlurayDVD ("Independence Day", 4, 7.81, 6, "BluRay DVD"); BlurayDVD b2 = new BlurayDVD ("X-Men", 8, 4.73, 2,"BluRay DVD"); BlurayDVD b3 = new BlurayDVD ("Jurassic Park", 3, 6.01, 3,"BluRay DVD"); BlurayDVD b4 = new BlurayDVD ("My Cousin Vinny", 4, 3.15, 4, "Standard DVD"); BlurayDVD b5 = new BlurayDVD("Independence DaySE", 4, 7.81, 6, "BluRay DVD"); bluList.add(b0); bluList.add(b1); bluList.add(b2); bluList.add(b3); bluList.add(b4); bluList.add(b5); Collections.sort(bluList, new Comparator<BlurayDVD>() { public int compare(BlurayDVD o1, BlurayDVD o2) { BlurayDVD p1 = (BlurayDVD) o1; BlurayDVD p2 = (BlurayDVD) o2; return p1.getDvdTitle().compareToIgnoreCase(p2.getDvdTitle()); } }); for (int i = 0; i < blu.length; i++) { System.out.printf(" %d\t%18s\t%d\t $%.2f\t$%.2f\t$%.2f\t%s", blu[i].dvdItem, blu[i].getDvdTitle(), blu[i].getDvdStock(), blu[i].getDvdPrice(), blu[i].value(), blu[i].getRestockFee(), blu[i].getCategory()); System.out.println(); // prints a blank line } System.out.println(); // prints a blank line System.out.printf("The total value of the entire inventory is $%.2f", total); System.out.println(); // prints a blank line //Example code to set a Frame visible in a main method. GUIFrame frame = new GUIFrame(); frame.setDVDs(blu); frame.pack(); frame.setVisible(true); }
Notice at the bottom there how you just create an instance of the GUI you are making to display the information? You should be able to set the DVD's with just a simple method like that, and have the GUI update its Components to display the correct data. Then you must also make sure to set the frame visible so you can see it.
- 11-05-2010, 04:53 PM #25
Member
- Join Date
- Oct 2010
- Posts
- 68
- Rep Power
- 0
These are the instructions for part 4:
"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."
Then, in part 5:
"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 the Java graphics classes."
Then part 6:
"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 item.
Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
Use exception handeling 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 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."
Thank you so much for all of your help.
- 11-05-2010, 05:22 PM #26
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
I would suggest you start by modifying your Inventory class to be more like an actual inventory, rather then just a testing class. Since you are going to need a way of storing/removing items from the inventory, start with these methods. Maybe make another class which could test to see if this is working.
- 11-05-2010, 09:56 PM #27
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
(At this late date this is just an aside) I agree. Before I asked if the method could always be called using some particular dvd reference and the answer is no. It only works here because the main() method creates some dvds. In general the value of the collection is quite well defined for an empty inventory but that value can't be obtained via a nonstatic DVD method.
So it makes no sense for the method to be nonstatic and, indeed, making it so limits its functionality. (In addition to making no sense for the method to be in that class in the first place which is well discussed above.)
Similar Threads
-
Help with inventory program part 5 PLEASE!
By Exether in forum New To JavaReplies: 2Last Post: 08-09-2010, 06:25 AM -
Inventory Program Part 2 of 6
By tlouvierre in forum New To JavaReplies: 2Last Post: 05-28-2009, 01:30 AM -
Inventory Program Part 3 ~ please help!
By marMcD in forum New To JavaReplies: 13Last Post: 02-25-2009, 05:57 AM -
Java Inventory Program Part 3
By ljk8950 in forum New To JavaReplies: 18Last Post: 07-28-2008, 05:47 AM -
Inventory part 2 help please
By badness in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks