|
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. -
class Inventory { //Begin Inventory Class
-
-
String Number; //stores Item number
-
String ItemName; //stores Item Name
-
int Quantity; //stores quanity
-
double Price; //stores price
-
double RestockFee; //stores restocking fee
-
-
public Inventory(String Item_Number, String Item_Name, int Stocked_Items, double Item_Price, double Item_Fee)
-
{
-
Number = Item_Number;
-
ItemName = Item_Name;
-
Quantity = Stocked_Items;
-
Price = Item_Price;
-
RestockFee = Item_Fee;
-
}
-
-
-
public void setItemItemName(String Item_Name) //Method to set and get the item Item Name
-
-
{
-
ItemName = Item_Name;
-
-
}
-
-
public String getItemItemName()
-
-
{
-
return ItemName;
-
-
}
-
-
public void setNumber(String Item_Number) //Method to set and get the Item Number
-
-
{
-
Number = Item_Number;
-
-
}
-
-
public String getNumber()
-
-
{
-
return Number;
-
-
}
-
-
public void setItemsInStock(int Stocked_Items) //Method to set and get the quantity in stock
-
-
{
-
Quantity = Stocked_Items;
-
-
}
-
-
public int getItemsInStock()
-
-
{
-
return Quantity;
-
-
}
-
-
public void setItemPrice(double Item_Price) //Method to set and get the Item Price
-
-
{
-
-
Price = Item_Price;
-
-
}
-
-
public double getItemPrice()
-
-
{
-
-
return Price;
-
-
}
-
-
-
public void setItemFee(double Item_Fee) //Method to set and get the restocking fee
-
-
{
-
RestockFee = Item_Fee;
-
-
}
-
-
public double getItemFee()
-
-
{
-
-
return RestockFee;
-
-
}
-
-
-
public double getInventoryValue() //Method to calculate the value of the inventory in stock
-
-
{
-
-
return Price * Quantity;
-
-
}
-
-
-
public static double getTotalValueOfAllInventory(Inventory [] inv)
-
-
{
-
double tot = 0.0;
-
-
for(int i = 0; i < inv.length; i++)
-
{
-
tot += inv[i].getInventoryValue();
-
}
-
return tot;
-
}
-
-
-
public String toString()
-
{
-
return "Manufacutre: "+ItemName + "\nItem Number: "+Number+"\nItem Price: $"+Price+"\nQuantity in Stock: "+Quantity + "\nRestocking Fee: $"+RestockFee + "\nInventory Value: $"+getInventoryValue();
-
-
}
-
-
} // end Inventory Class
-
-
-
//============================================================================================//
-
-
class PC extends Inventory { // Begin PC Class
-
-
String Workstation; // Subclass to add to PC
-
double reRestockFee; // Add Restock Fee to Inventory Value
-
-
-
public PC(String Workstation, double reRestockFee, String Item_Number, String Item_Name, int Stocked_Items,
-
double Item_Price, double Item_Fee) {
-
super(Item_Number, Item_Name, Stocked_Items, Item_Price, Item_Fee);
-
this.Workstation = Workstation;
-
this.reRestockFee = reRestockFee;
-
}
-
-
public double getInventoryValue() // Figures total inventory value including restocking fee
-
{
-
return super.getInventoryValue() + (super.getInventoryValue() * reRestockFee);
-
}
-
-
public String toString()
-
{
-
StringBuffer sb = new StringBuffer("\nWorkstation: ").append(Workstation).append("\n");
-
sb.append(super.toString());
-
-
return sb.toString();
-
}
-
-
} // End PC Class
-
-
-
//============================================================================================//
-
-
class Inventory4 // Begin Inventorypart4 Class
-
-
{
-
public static void main(String args[])
-
{
-
-
double restockFee = 0.05;
-
-
PC[] inventory = new PC[8]; //create array of PC
-
-
inventory[0] = new PC("Dell 4200" ,restockFee, "100","Dell" , 7, 799.00, 39.95);
-
inventory[1] = new PC("Dell 4400" ,restockFee, "101","Dell" , 6, 899.00, 44.95 );
-
inventory[2] = new PC("Dell 4600",restockFee, "102","Dell", 5, 1199.00, 59.95);
-
inventory[3] = new PC("Dell 5600",restockFee,"103","Dell" , 3, 1299.00, 64.95);
-
inventory[4] = new PC("HP 8700",restockFee,"200","HP" , 2, 1599.00, 79.95);
-
inventory[5] = new PC("HP 8800",restockFee,"201","HP" , 10, 2299.00, 114.95);
-
inventory[6] = new PC("HP 9400",restockFee,"202","HP" , 6, 2500.00, 125);
-
inventory[7] = new PC("HP 9600",restockFee,"203","HP" , 1, 2999.00, 149.95);
-
-
-
PC temp[] = new PC[1];
-
-
System.out.print( "Inventory of Workstations: " ); // display title
-
System.out.println();
-
System.out.println();
-
-
-
-
// Sorting Inventory Information
-
for(int j = 0; j < inventory.length - 1; j++)
-
{
-
for(int k = 0; k < inventory.length - 1; k++)
-
{
-
if(inventory[k].getItemItemName().compareToIgnoreCase(inventory[k+1].getItemItemName()) > 0)
-
{
-
temp[0] = inventory[k];
-
inventory[k] = inventory[k+1];
-
inventory[k+1] = temp[0];
-
}
-
}
-
}
-
-
-
// Print Inventory Information
-
for(int j = 0; j < inventory.length; j++)
-
{
-
System.out.println(inventory[j].toString());
-
}
-
-
-
System.out.printf("\n\nTotal value of Workstation Inventory: $%.2f\n\n" , Inventory.getTotalValueOfAllInventory(inventory));
-
return;
-
-
}
-
} // End Inventory4 Class
-
| |
Share:
Expert 512MB |
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?
| | |
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,
| | 8TB |
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.
| | Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
36 posts
views
Thread by toedipper |
last post: by
|
11 posts
views
Thread by Michael Thomas |
last post: by
| | | | | | | | | | | | | | | | | |