Hello all, can someone take a look at my inventory program code for part 3 of the program mod. The program outputs, but I am still experiencing a few errors. If someone could take a look and let me know what to change I would greatly appreciate it.
This is my assignment:
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 department in which the product belongs, 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.
// Fig 3.0: Inventory.java
// This program calculates inventory value
import java.util.Scanner;
import java.util.Arrays;
public class Inventory
{
// main method begins program execution
public static void main(String args[] )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// display a welcome message to the InventoryProgramPart3 user
System.out.println( "Welcome to Inventory Program Part 3!" );
// office supplies
Camera[] myCamera = new Camera[100]; // an array of 100 supplies
myCamera[0] = new Camera(0,"Sony",4000, 60, 200.00 );
myCamera[1] = new Camera(1,"Toshiba",3000, 50, 150.00 );
myCamera[2] = new Camera(2,"Phillips",2000, 40, 100.00 );
// display the inventories one at a time
Camera.showInventory();
Camera.showInventory();
// sort cameras by name
for ( int i = 0; i < args.length; i++ )
System.out.println( args[i] + ", " );
double array[] = { 100.00, 150.00, 200,00 };
double total = 0;
// add each element's value to total
for ( int counter = 0; counter < array.length; counter++)
total += array[ counter ];
System.out.printf( "\nTotal inventory value is: $%.2f\n", total );
System.out.println( "\nThank you for using Inventory Program Part 3!\n" );
} // end method main
private Inventory() {
}
} // end class Inventory
class Camera
{
private String UnitName = new String();
private int UnitNumber;
private int NumberofUnits;
private double UnitPrice;
// set supplies number
public void setUnitName( String Name )
{
this.UnitName = Name;
} // end method set unit name
// return unit name
public String getUnitName()
{
return UnitName;
} // end method get unit name
// set supplies name
public void setUnitNumber( int Number)
{
this.UnitNumber = Number;
} // end method set unit number
// return unit number
public String getUnitNumber()
{
return UnitNumber;
} // end method get unit number
// set number of units
public void setNumberofUnits( int Units )
{
this.NumberofUnits = Units;
} // end method set number of units
// return number of units
public int getNumberofUnits()
{
return NumberofUnits;
} // end method get supplies units
// set supplies price
public void setUnitPrice( double price )
{
this.UnitPrice = price;
} // end method set unit price
// return unit price
public double getUnitPrice()
{
return UnitPrice;
} // end method get unit price
// calculate unit price inventory value
public double getValue()
{
return getNumberofUnits() * getUnitPrice();
} // end method supplies inventory value
// four-argument constructor
Camera( String Name, int Number, int Units, double price )
{
UnitName = Name;
UnitNumber = Number;
NumberofUnits = Units;
UnitPrice = Price;
} // end four-argument constructor
// display inventory
public void showInventory()
{
System.out.println(); // outputs blank line
System.out.println( "Product Name: "+getUnitName() );
System.out.println( "Product Number: "+getUnitNumber() );
System.out.println( "Units in Stock: "+getNumberofUnits() );
System.out.printf( "Unit Price: $%.2f", getUnitPrice());
Camera myCamera = new Camera
(0, "Sony", 60, 200.0, "Toshiba" );
System.out.println( "\nManufacturer: "+Camera.getCameraManufacturer() );
// value() method and display the value
System.out.printf( "\nInventory value of "+getUnitName()+ " is = $%.2f\n",
getValue() );
} // end display inventory
} // end class Camera
class InventoryProgram extends Inventory
{
// holds the supplies manufacturer
private String CameraManufacturer;
// five-argument constructor
InventoryProgram( String Name, int Number, int Units,
double price, String manufacturer )
{
super(Name, Number, Units, Price );
CameraManufacturer = manufacturer;
} // end five-argument constructor
// set camera manufacturer
public void setCameraManufacturer( String manufacturer )
{
this.CameraManufacturer = manufacturer;
} // end method set supplies manufacturer
// return camera manufacturer
public String getCameraManufacturer()
{
return CameraManufacturer;
} // end method get supplies manufacturer
// add 5% restocking fee
public double getPrice()
{
return super.getValue() * 1.05;
} // end method return camera manufacturer
// calculate restocking fee
public double getRestockingFee()
{
return super.getValue() * .05;
} //end method calculate restocking fee
//return String representation of CameraManufacturer
@Override
public String toString()
{
String formatString = "Manufacturer: %s";
formatString += "Restocking Fee: $%.2f";
formatString = String.format( formatString, CameraManufacturer,
super.getPrice() * 0.05 );
return( formatString + super.toString() );
} // end toString()
// display inventory
public void showInventory()
{
super.showInventory();
System.out.println( toString() );
System.out.println( "\nManufacturer: "+getCameraManufacturer() );
// Display value plus restocking fee
System.out.printf( "\nInventory value of "+CameraName+ " is = $%.2f\n",
getRestockingFee() );
} // end method display inventory
} // end class manufacturer