Need help with subclass constructor (i think)
I have a three file program. I am having a problem with my subclass Maker and my array in my InventoryMain. Any help is greatly appreciated.
Here is my main:
package inventorymain;
import java.text.NumberFormat;// used to format currency
import inventorymain.Maker;
publicclass InventoryMain
{
// main method begins execution of java application
publicstaticvoid main(String[] args)
{
//variable for formatting currency
NumberFormat nf = NumberFormat.getCurrencyInstance(java.util.Locale.US);
//create array for products in inventory
Maker []proMaker =new Maker[10];//initializes product array
//enter elements into array
proMaker[0] =new Maker( 1,"pens",1.59,346,"Bic");
proMaker[1] =new Maker( 2,"pencils", .59, 487,"Mead");
proMaker[2] =new Maker( 3,"markers", 1.29, 168,"Sharpie");
proMaker[3] =new Maker( 4,"paperclips", 1.19, 136,"Dennison");
proMaker[4] =new Maker( 5,"glue", .79, 72,"Elmer's");
proMaker[5] =new Maker( 6,"tape", .49, 127,"3m");
proMaker[6] =new Maker( 7,"paper", 1.79, 203,"Mead");
proMaker[7] =new Maker( 8,"staples", 1.19, 164,"Pentech");
proMaker[8] =new Maker( 9,"folders", .49, 238,"Mead");
proMaker[9] =new Maker( 10,"rulers", .17, 123,"Stanley");
for (int i = 0; i < proMaker.length; i++)// for loop displays array elements
{
System.out.println("Product name: " + proMaker[i].getName());//displays product name
System.out.println("Manufacturer: " + proMaker[i].getManufact());//displays product manufacturer
System.out.println("Item number: " + proMaker[i].getNumberCode());//displays product number
System.out.println("Unit price: " + proMaker[i].getPrice());//displays price per unit
}// end for loop
//Sort elements in array in alphabetical oerder by product name
proMaker[0].sortItems(proMaker);
System.out.println();//inserts blank line
System.out.println();//inserts blank line
System.out.println("Alphabetical by product name");
System.out.println();//inserts blank line
System.out.println();//inserts blank line
for (int c = 0; c < proMaker.length;c++)
{
System.out.println("Product name: " + proMaker[c].getName());//displays product name
System.out.println("Manufacturer: " + proMaker[c].getManufact());//displays product manufacturer
System.out.println("Item number: " + proMaker[c].getNumberCode());//displays item number
System.out.println("Unit price: " + proMaker[c].getPrice());//displays price per unit
System.out.println("The value of " + proMaker[c].getName() +" left in the inventory is: "+nf.format (proMaker[c].getSum()));//displays inventory product value
}//end for loop
System.out.println();//enters blank line
System.out.println();//enters blank line
System.out.println("The value of all merchandise in inventory is: " + nf.format (proMaker[0].totalAllInventory));
}//end Main
}//end class InventoryMain
here are my errors when compiling:
InventoryMain.java:33: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[0] = new Maker( 1, "pens",1.59,346,"Bic");
InventoryMain.java:34: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[1] = new Maker( 2, "pencils", .59, 487,"Mead");
InventoryMain.java:35: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[2] = new Maker( 3, "markers", 1.29, 168,"Sharpie");
InventoryMain.java:36: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[3] = new Maker( 4, "paperclips", 1.19, 136,"Dennison");
InventoryMain.java:37: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[4] = new Maker( 5, "glue", .79, 72,"Elmer's");
InventoryMain.java:38: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[5] = new Maker( 6, "tape", .49, 127,"3m");
InventoryMain.java:39: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[6] = new Maker( 7, "paper", 1.79, 203,"Mead");
InventoryMain.java:40: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[7] = new Maker( 8, "staples", 1.19, 164,"Pentech");
InventoryMain.java:41: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[8] = new Maker( 9, "folders", .49, 238,"Mead");
InventoryMain.java:42: cannot find symbol
symbol : constructor Maker(int,java.lang.String,double,int,java.lang.String)
location: class inventorymain.Maker
proMaker[9] = new Maker( 10, "rulers", .17, 123,"Stanley");
10 errors
BUILD FAILED (total time: 3 seconds)
Here is my Maker.java
package inventorymain;
publicclass Makerextends Inventory
{
String manufact;
public Maker(long itemNum, String name,long units,double price, String manufact)// Constructor for varibles
{
super(itemNum, name, units, price);
this.manufact = manufact;
}
publicvoid setManufact( String manufact)
{
this.manufact = manufact;
}
public String getManufact()
{
return manufact;
}
publicdouble getSum()//method to calculate sum
{
double itemTotal;
double stockFee;
itemTotal = (productUnits * unitPrice);
stockFee = itemTotal + (itemTotal * .05);
return stockFee;
}
}// end of class Maker
_
Can anyone help? Both my Inventory.java and Maker.java compile correctly. just incase anyone who wants to help and also needs my Inventory.java; here it is:
package inventorymain;//file assigned to inventorymain package
import java.text.NumberFormat;
import inventorymain.Maker;
publicclass Inventory
{
// set variables
protectedlong numberCode;
protected String productName;
protectedlong productUnits;
protecteddouble unitPrice;
protectedstaticdouble totalAllInventory;
NumberFormat nf = NumberFormat.getCurrencyInstance(java.util.Locale.US);
public Inventory(long itemNum, String name,long units,double price)//varibles for constructor
{
numberCode = itemNum;//variable initialized
productName = name;//variable initialized
productUnits = units;//variable initialized
unitPrice = price;//variable initialized
}
// All setters and getters
public Inventory()
{
numberCode = 0;
}
publicvoid setnumberCode(long itemNum)
{
numberCode = itemNum;
}
publicvoid setName(String name)
{
productName = name;
}
publicvoid setProductUnits(long units)
{
productUnits = units;
}
publicvoid setUnitPrice(double price)
{
unitPrice = price;
}
publiclong getNumberCode()
{
return numberCode;
}
public String getName()
{
return productName;
}
publicdouble getUnits()
{
return productUnits;
}
publicdouble getPrice()
{
return unitPrice;
}
publicdouble totalAllInventory( Inventory[] myProduct1)//method totals value of all merchandise
{
double retotal = 0;
for (int i = 0; i < myProduct1.length; i++)// for loop for totaling
{
retotal = retotal + (getUnits() * getPrice());
}
return retotal;
}//end totalAllInventory
publicvoid sortItems(Inventory[] myProducts)
{
int a;
int b;
int sortNames = myProducts.length - 1;
String tempName;
long tempItemNum;
long tempUnits;
double tempPrice;
for (a = 0; a < sortNames; ++a)
for (b = 0; b < sortNames; ++b)
if(myProducts[b].productName.compareTo(myProducts[b + 1].productName) >0)
{
tempName = myProducts[b].productName;
myProducts[b].productName = myProducts[b + 1].productName;
myProducts[b + 1].productName = tempName;
tempItemNum = myProducts[b].numberCode;
myProducts[b].numberCode = myProducts[b + 1].numberCode;
myProducts[b + 1].numberCode = tempItemNum;
tempUnits = myProducts[b].productUnits;
myProducts[b].productUnits = myProducts[b + 1].productUnits;
myProducts[b + 1].productUnits = tempUnits;
tempPrice = myProducts[b].unitPrice;
myProducts[b].unitPrice = myProducts[b + 1].unitPrice;
myProducts[b + 1].unitPrice = tempPrice;
}//end if
}// end class Inventory
}// end class Inventory

