Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    ladykrimson is offline Member
    Join Date
    Oct 2010
    Posts
    69
    Rep Power
    0

  2. #22
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    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.

  3. #23
    ladykrimson is offline Member
    Join Date
    Oct 2010
    Posts
    69
    Rep Power
    0

    Default

    Quote Originally Posted by StormyWaters View Post
    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.
    OK, the GUI must display the output....like so:


  4. #24
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    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.

  5. #25
    ladykrimson is offline Member
    Join Date
    Oct 2010
    Posts
    69
    Rep Power
    0

    Default

    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.

  6. #26
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    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.

  7. #27
    pbrockway2 is online now Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,571
    Rep Power
    12

    Default

    Quote Originally Posted by StormyWaters View Post
    It doesn't have to be static, though it makes absolutely no sense for it not to be.

    (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.)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Help with inventory program part 5 PLEASE!
    By Exether in forum New To Java
    Replies: 2
    Last Post: 08-09-2010, 07:25 AM
  2. Inventory Program Part 2 of 6
    By tlouvierre in forum New To Java
    Replies: 2
    Last Post: 05-28-2009, 02:30 AM
  3. Inventory Program Part 3 ~ please help!
    By marMcD in forum New To Java
    Replies: 13
    Last Post: 02-25-2009, 06:57 AM
  4. Java Inventory Program Part 3
    By ljk8950 in forum New To Java
    Replies: 18
    Last Post: 07-28-2008, 06:47 AM
  5. Inventory part 2 help please
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •