I can not figure out why my output doesn't seem to call from my manufacturer class to output the data. Just looking for advise as what I May have done wrong.
package inventory.program2;
import java.io.*;
import java.text.*;
/**
*
* @author chrischad
*/
public class InventoryProgram2 {
public InventoryProgram2() throws IOException {
Inventory aInventory = new Inventory();
int Count = 0;
//create a reader
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Welcome to the Inventory program\n\n");
while ( Count <100)
{
System.out.print("Enter product Name or Exit to stop: ");
String invName = input.readLine();
if (invName.equalsIgnoreCase("Exit"))
{
break;
}
//prompt for input
System.out.print("Inventory number: " );
String invNumber = input.readLine();
System.out.print("Enter manufacturer: " );
String invManu = input.readLine();
System.out.print("How many in Stock: " );
int invStock = Integer.valueOf(input.readLine()).intValue();
while (invStock < 0 )
{
System.out.println("Error: Please insert a positive number of stock: " );
invStock = Integer.valueOf(input.readLine()).intValue();
}
System.out.print("Enter Price: ");
double invPrice = Double.valueOf(input.readLine()).doubleValue();
while (invPrice < 0.0)
{
System.out.println("Error: Please enter a positive Price: ");
invPrice = Double.valueOf(input.readLine()).doubleValue();
}
//create an inventory
Supply supplies = new Supply(invName, invNumber, invStock, invPrice);
aInventory.addSupply(supplies);
Count++;
System.out.println();
}
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();
aInventory.sortInventory();
//print out inventory
for (int i = 0; i< aInventory.getNumberOfSupply();i++)
{
Supply supplies = aInventory.getSupply(i);
{
System.out.println("Product name: " + supplies.getName());
System.out.println("Inventory number: " + supplies.getInvNumber());
System.out.println("Manufacturer: " + supplies.getManu());
System.out.println("Stock: " + supplies.getInvStock());
System.out.println("Price: " + moneyFormat.format(supplies.getInvPrice()));
System.out.println("Restocking Fee: " + moneyFormat.format(supplies.restockingFee()));
System.out.println("Inventory Value: " + moneyFormat.format(supplies.getInvValue()));
System.out.println();
}
System.out.println("Total Inventory Value: " + moneyFormat.format(aInventory.getTotalValue()));
System.out.println();
System.out.println("Closing Inventory program\n\n");
}
}
public static void main(String[] args) throws IOException{
InventoryProgram2 inventoryProgram2 = new InventoryProgram2();
}
}
public class Supply implements Comparable {
public String name;
public String invNumber;
public int invStock;
public double invPrice;
String getManu;
public Supply( )
{
name = "";
invNumber = "0";
invStock = 0;
invPrice = 0.00;
}
public Supply(String name, String invNumber, int invStock, double invPrice)
{
this.name = name;
this.invNumber = invNumber;
this.invStock = invStock;
this.invPrice = invPrice;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getInvNumber()
{
return invNumber;
}
public void setInvNumber(String invNumber)
{
this.invNumber = invNumber;
}
public int getInvStock()
{
return invStock;
}
public void setInvStock(int invStock)
{
this.invStock = invStock;
}
public double getInvPrice()
{
return invPrice;
}
public void setInvPrice(double invPrice)
{
this.invPrice = invPrice;
}
public double getInvValue()
{
return invStock * invPrice;
}
@Override
public int compareTo(Object object)
{
if ( name == null )
{
return -1;
}
if ( object == null )
{
return 1;
}
return name.compareTo(((Supply)object).getName());
}
}
class Manufacturer extends Supply {
private String manu;
public Manufacturer()
{
super();
manu = "";
}
/**
*
* @param name
* @param invNumber
* @param manu
* @param invStock
* @param invPrice
*/
public Manufacturer(String name, String invNumber, String manu, int invStock, double invPrice)
{
super(name, invNumber, invStock, invPrice);
this.manu = manu;
}
/**
*
* @return
*/
public String getManu(String Manu)
{
return super.getManu;
}
public void setmanu(String manu)
{
this.manu = manu;
}
@Override
public double getInvValue()
{
return super.getInvValue() * 1.05;
}
public double restockingFee()
{
return super.getInvValue() * 0.05;
}
@Override
public String toString(){
return String.format
("Item Number:\t\t%d\nItem Name:\t\t%s\nItem Size:\t\t%d oz\nItems In Stock:\t\t%d\n"+
"Cost Per Item:\t\t$%.2f\nTotal Product Cost:\t$%.2f\nRestock Fee:\t\t$%.2f",
invNumber, name, invStock, manu, invPrice, getInvValue(), restockingFee());
}
}