Hello, I am having some trouble compiling my code for the inventory program part 2, if someone could take a look and help me out I would really appreciate it. Thanks.
I am required to implement an array to store, monitor, and retrieve data for camera inventory.
// Fig 2.4: InventoryProgram2.java
// Creating Inventory Program for Camera Inventory
import java.util.*;
import java.text.NumberFormat;
import java.text.DecimalFormat;
class Inventory
{
private static class UnitName {
public UnitName() {
}
}
private String ItemName;// class variable stores item name
private int ItemNumber;// class variable stores item number
private int NumberofUnits;// class variable stores number of units
private double UnitPrice;// class variable stores unit price
public Inventory(String name, int number, int Number, double price)
// Constructor
{
ItemName = ItemName;
ItemNumber = ItemNumber;
NumberofUnits = NumberofUnits;
UnitPrice = UnitPrice;
}
// method to set item name
public void setName(String name)
{
this.ItemName = ItemName;
}
// method to get Camera name
public String getItemName()
{
return ItemName;
}
// method to set unit number
public void setItemNumber(int number)
{
this.ItemNumber = ItemNumber;
}
// method to get item number
public int getItemNumber()
{
return ItemNumber;
}
// method to set number of units
public int setNumberofUnits()
{
this.NumberofUnits = NumberofUnits;
}
// method to get number of units
public int getNumberofUnits()
{
return NumberofUnits;
}
// method to set unit price
public double setUnitPrice()
{
this.UnitPrice = UnitPrice;
}
// method to get unit price
public double getUnitPrice()
{
return UnitPrice;
}
// method to calculate inventory value
public double calculateInventoryValue()
{
return NumberofUnits * UnitPrice;
}
// product sorting
public int compareTo (Object o)
{
Camera s = (Camera)o;
return UnitName.compareTo(s.getUnitName());
}
// return string unit information
@Override
public String toString()
{
System.out.println();return"Name;"+UnitName+ "\nNumber;"+UnitNumber+"\nNumberofUnits:$"+NumberofUnits+
"\nPrice:"+UnitPrice+ "\nValue:$"+calculateInventoryValue();
} // end main method
} // end class InventoryProgram2
class Camera
{
//main method begin execution of java application
public static void main(String argus[], String value)
{
//create product array for camera
Camera[]products = new Camera[5];
// camera inventory
Camera a1 = new Camera("Sony", 10, 44, 200.0);
Camera a2 = new Camera("Toshiba", 10, 43, 150.0);
Camera a3 = new Camera("Phillips", 10, 45, 250.0);
products[1] = a1;
products[2] = a2;
products[3] = a3;
double UnitPrice = 0.0;
for(int i=0;i<6;i++)
{
value = NumberofUnits + UnitPrice[i].calculateInventoryValue();
}
// Display Inventory total value
System.out.printf("Total value of entire Inventory is:$%.2f",value);
System.out.println();
Arrays.sort(products);
for(Camera s:products)
{
System.out.println(s);
System.out.println();
}
}// end main method
public Camera() {
}
}// end class InventoryPart2