Raven50 Raven50 - 5 months ago 21
Java Question

Java Code for Inventory Program Part 3 will not compile

Made correction to previous errors, this error now comes up.

C:\Documents and Settings\AdminUser\My Documents\InventoryPart3.java:93: invalid method declaration; return type required
public Television(int ItemNumber, String ProductName, int UnitsStock, double UnitPrice, String mfgName) {
^
1 error

Tool completed with exit code 1





class Television { //class name and attributes

private String ItemNumber; //item # of product
private String ProductName; //product name
private double UnitsStock; //# of units in stock
private double UnitPrice; //Price per unit
private String SerialNumber; //serial number of product
private double InventoryValue; //The dollar value of the inventory in stock

//constructor

public Television (String item, String product, double units, double price, String serial) {

ItemNumber = item;
ProductName = product;
UnitsStock = units;
UnitPrice = price;
SerialNumber = serial;

} //end constructor

///getter and setter methods for Television

public void setItemNumber (String item) { //setter for item number
this.ItemNumber = item;
} //end setter item number

public String getItemNumber() { //getter for item number
return ItemNumber;
} //end getter item number

public void setProductName (String product) { //setter for product name
this.ProductName = product;
} //end setter product name

public String getProductName() { //getter for product name
return ProductName;
} //end getter product name

public void setUnitsStock (double units) { //setter for units in stock
this.UnitsStock = units;
} //end setter units in stock

public double getUnitsStock() { //getter for units in stock
return UnitsStock;
} //end getter units in stock

public void setUnitPrice (double price) { //setter for unit price
this.UnitPrice = price;
} //end setter unit price

public double getUnitPrice() { //getter for unit price
return UnitPrice;
} //end getter for unit price

public void setSerialNumber (String serial) { //setter for serial number
this.SerialNumber = serial;
}//end setter for serial number

public String getSerialNumber() { //getter for serial number
return SerialNumber;
}//end getter for serial number



//calculate individual product inventory value

public double getInventoryValue(){
return UnitsStock * UnitPrice;

}//end calculate individual product inventory value


//calculate total inventory value
public double calculateInventory(){
return UnitPrice * UnitsStock;
}//end calculate total inventory value

///end getter and setter methods for Laptop

} //end class Television

class Manufacturer extends Television {
private String manufacturerName;

//constructor

public Television(int ItemNumber, String ProductName, int UnitsStock, double UnitPrice, String mfgName) {
super(ItemNumber, ProductName, UnitsStock, UnitPrice, ManufacturerName);

this.manufacturerName = mfgName;

}//end constructor

//getter and setter for class Manufacturer

public void setmanufacturerName(String mfgName) {
this.manufacturerName = mfgName;
}

public String getmanufacturerName() {
return manufacturerName;
}

//end getter and setter for class Manufacturer

//calculate total inventory value

public double calculateInventory(){
return ((UnitPrice * UnitsStock));

}//end calculate total inventory value

//calculate restocking fee method

public double getcalculateRestockFee() {
return getInventoryValue();

}//end calculate restocking fee method

}//end class Manufacturer

Answer

So there are two errors. The first one occurs on line 93 of the file InventoryPart3.java. On that line you will find the code:

 super(ItemNumber, ProductName, UnitsStock, UnitPrice);

Which is actually a call to the constructor of the television class. However, the constructor of the television class accepts 5 parameters: String, String, double, double, String but you are passing only 4.

The second error occurs on line 120 of the same file. In this case you seem to be calling a method but you left out the parenthesis. That is, the code should be:

   getInventoryValue()