By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

How to design an Inventory Program GUI

P: 8
I need some help if someone could help me. I know everyone is asking for help in java. But for some reason I'm the same as everyone else when it comes to programming in java. I have an inventory program that I have built so far with no problem. But I cannot figure out how to turn it into a GUI application.
This is what I'm trying to get it to do.

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.

Expand|Select|Wrap|Line Numbers
  1. class Inventory { //Begin Inventory Class
  2.  
  3.     String Number; //stores Item number
  4.     String ItemName; //stores Item Name
  5.     int Quantity; //stores quanity
  6.     double Price; //stores price
  7.     double RestockFee; //stores restocking fee
  8.  
  9.     public Inventory(String Item_Number, String Item_Name, int Stocked_Items, double Item_Price, double Item_Fee)
  10.     {
  11.         Number = Item_Number;
  12.         ItemName = Item_Name;
  13.         Quantity = Stocked_Items;
  14.         Price = Item_Price;
  15.         RestockFee = Item_Fee;
  16.     }
  17.  
  18.  
  19.     public void setItemItemName(String Item_Name) //Method to set and get the item Item Name
  20.  
  21.     {
  22.         ItemName = Item_Name;
  23.  
  24.     }
  25.  
  26.     public String getItemItemName()
  27.  
  28.     {
  29.         return ItemName;
  30.  
  31.     }
  32.  
  33.     public void setNumber(String Item_Number) //Method to set and get the Item Number
  34.  
  35.     {
  36.         Number = Item_Number;
  37.  
  38.     }
  39.  
  40.     public String getNumber()
  41.  
  42.     {
  43.         return Number;
  44.  
  45.     }
  46.  
  47.     public void setItemsInStock(int Stocked_Items) //Method to set and get the quantity in stock
  48.  
  49.     {
  50.         Quantity = Stocked_Items;
  51.  
  52.     }
  53.  
  54.     public int getItemsInStock()
  55.  
  56.     {
  57.         return Quantity;
  58.  
  59.     }
  60.  
  61.     public void setItemPrice(double Item_Price) //Method to set and get the Item Price
  62.  
  63.     {
  64.  
  65.         Price = Item_Price;
  66.  
  67.     }
  68.  
  69.     public double getItemPrice()
  70.  
  71.     {
  72.  
  73.         return Price;
  74.  
  75.     }
  76.  
  77.  
  78.     public void setItemFee(double Item_Fee) //Method to set and get the restocking fee
  79.  
  80.     {
  81.         RestockFee = Item_Fee;
  82.  
  83.     }
  84.  
  85.     public double getItemFee()
  86.  
  87.     {
  88.  
  89.         return RestockFee;
  90.  
  91.     }
  92.  
  93.  
  94.     public double getInventoryValue() //Method to calculate the value of the inventory in stock
  95.  
  96.     {
  97.  
  98.         return Price * Quantity;
  99.  
  100.     }
  101.  
  102.  
  103.     public static double getTotalValueOfAllInventory(Inventory [] inv)
  104.  
  105.     {
  106.         double tot = 0.0;
  107.  
  108.         for(int i = 0; i < inv.length; i++)
  109.         {
  110.         tot += inv[i].getInventoryValue();
  111.         }
  112.         return tot;
  113.     }
  114.  
  115.  
  116.     public String toString()
  117.     {
  118.     return "Manufacutre: "+ItemName + "\nItem Number: "+Number+"\nItem Price: $"+Price+"\nQuantity in Stock: "+Quantity + "\nRestocking Fee: $"+RestockFee + "\nInventory Value: $"+getInventoryValue();
  119.  
  120.     }
  121.  
  122. } // end Inventory Class
  123.  
  124.  
  125. //============================================================================================//
  126.  
  127. class PC extends Inventory { // Begin PC Class
  128.  
  129.     String Workstation;                    // Subclass to add to PC
  130.     double reRestockFee;                // Add Restock Fee to Inventory Value
  131.  
  132.  
  133.         public PC(String Workstation, double reRestockFee, String Item_Number, String Item_Name, int Stocked_Items,
  134.         double Item_Price, double Item_Fee) {
  135.         super(Item_Number, Item_Name, Stocked_Items, Item_Price, Item_Fee);
  136.         this.Workstation = Workstation;
  137.         this.reRestockFee = reRestockFee;
  138.     }
  139.  
  140.     public double getInventoryValue() // Figures total inventory value including restocking fee
  141.     {
  142.         return  super.getInventoryValue() + (super.getInventoryValue() * reRestockFee);
  143.     }
  144.  
  145.     public String toString()
  146.     {
  147.         StringBuffer sb = new StringBuffer("\nWorkstation: ").append(Workstation).append("\n");
  148.         sb.append(super.toString());
  149.  
  150.         return sb.toString();
  151.     }
  152.  
  153. } // End PC Class
  154.  
  155.  
  156. //============================================================================================//
  157.  
  158. class Inventory4 // Begin Inventorypart4 Class
  159.  
  160. {
  161.     public static void main(String args[])
  162.     {
  163.  
  164.         double restockFee = 0.05;
  165.  
  166.         PC[] inventory = new PC[8]; //create array of PC 
  167.  
  168.         inventory[0] = new PC("Dell 4200" ,restockFee, "100","Dell" , 7, 799.00, 39.95);  
  169.         inventory[1] = new PC("Dell 4400" ,restockFee, "101","Dell" , 6,  899.00, 44.95 ); 
  170.         inventory[2] = new PC("Dell 4600",restockFee, "102","Dell", 5,  1199.00, 59.95);  
  171.         inventory[3] = new PC("Dell 5600",restockFee,"103","Dell" , 3, 1299.00, 64.95);     
  172.         inventory[4] = new PC("HP 8700",restockFee,"200","HP" , 2, 1599.00, 79.95);    
  173.         inventory[5] = new PC("HP 8800",restockFee,"201","HP" , 10, 2299.00, 114.95); 
  174.         inventory[6] = new PC("HP 9400",restockFee,"202","HP" , 6, 2500.00, 125); 
  175.         inventory[7] = new PC("HP 9600",restockFee,"203","HP" , 1, 2999.00, 149.95); 
  176.  
  177.  
  178.         PC temp[] = new PC[1];
  179.  
  180.          System.out.print( "Inventory of Workstations: " ); // display title
  181.             System.out.println();
  182.             System.out.println();
  183.  
  184.  
  185.  
  186. // Sorting Inventory Information
  187.         for(int j = 0; j < inventory.length - 1; j++)
  188.         {
  189.             for(int k = 0; k < inventory.length - 1; k++)
  190.             {
  191.                 if(inventory[k].getItemItemName().compareToIgnoreCase(inventory[k+1].getItemItemName()) > 0)
  192.                 {
  193.                     temp[0] = inventory[k];
  194.                     inventory[k] = inventory[k+1];
  195.                     inventory[k+1] = temp[0];
  196.                 }
  197.             }
  198.         }
  199.  
  200.  
  201. // Print Inventory Information
  202.         for(int j = 0; j < inventory.length; j++)
  203.         {
  204.             System.out.println(inventory[j].toString());
  205.         }
  206.  
  207.  
  208.         System.out.printf("\n\nTotal value of Workstation Inventory: $%.2f\n\n" , Inventory.getTotalValueOfAllInventory(inventory));
  209.         return;
  210.  
  211.     }
  212. } // End Inventory4 Class
  213.  
Nov 12 '07 #1
Share this Question
Share on Google+
3 Replies


SammyB
Expert 100+
P: 807
You need to answer the following questions:
1) What type of GUI am I going to design? Swing, Applet, JFrame, or ?
2) What controls do I need to add?
Nov 13 '07 #2

P: 8
You need to answer the following questions:
1) What type of GUI am I going to design? Swing, Applet, JFrame, or ?
2) What controls do I need to add?
The gui program will be built using Swing. I have tried to program using the JAVA gui before, but I am not having any luck. I really dont know were to start. I have done ok up until now. Right now I just need The application to use a GUI to display the product information of one product, 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.The GUI displays the additional attribute from the subclass, the restocking fee, and the value of the entire inventory.

Thanks,
Nov 20 '07 #3

10K+
P: 13,264
The gui program will be built using Swing. I have tried to program using the JAVA gui before, but I am not having any luck. I really dont know were to start. I have done ok up until now. Right now I just need The application to use a GUI to display the product information of one product, 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.The GUI displays the additional attribute from the subclass, the restocking fee, and the value of the entire inventory.

Thanks,
Here's Sun's swing tutorial.
Nov 20 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.