Hello all,
I am working on assignment for class and I thought I had this one but something is wrong. This is an inventory control program that needs to display 7 items with the item number, name, number in stock, price and value. The program works for item 7 but all items before are not showing. I am sure this is a dumb error but any assistance in dumbed down language would be much appreciated.
This is how it runs:
run:
inventory1.Supplies@15db9742
inventory1.Supplies@6d06d69c
inventory1.Supplies@7852e922
inventory1.Supplies@4e25154f
inventory1.Supplies@70dea4e
inventory1.Supplies@5c647e05
inventory1.Supplies@33909752
The item number is 7.0
Name of the item is sticky note
The price of each item is 1.0
The number of items in stock are 30.0
The value of the inventory is 30.0
BUILD SUCCESSFUL (total time: 0 seconds)
This is my code:
public class Inventory1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Supplies
Supplies;
Supplies = new Supplies(1, "whiteout", 5, 1.00);
System.out.println(Supplies);
Supplies = new Supplies(2, "Pen", 50, .50);
System.out.println(Supplies);
Supplies = new Supplies(3, "pencil", 50, .25);
System.out.println(Supplies);
Supplies = new Supplies(4, "box of paper", 10, 20.00);
System.out.println(Supplies);
Supplies = new Supplies(5, "sharpie", 100, 1.00);
System.out.println(Supplies);
Supplies = new Supplies(6, "coffee cup", 5, 5.00);
System.out.println(Supplies);
Supplies = new Supplies(7, "sticky note", 30, 1.00);
System.out.println(Supplies);
System.out.println("The item number is " + Supplies.getItemNumber());
System.out.println("Name of the item is " + Supplies.getProductName());
System.out.println("The price of each item is " + Supplies.getItemPrice());
System.out.println("The number of items in stock are " + Supplies.getInStock());
System.out.println("The value of the inventory is " + Supplies.value());
}// end main
}//end inventory class
//create class
class Supplies{
private double itemNumber;
private String productName;
private double inStock;
private double itemPrice;
public Supplies(double number, String name, double stock, double price){
itemNumber = number;
productName = name;
inStock = stock;
itemPrice = price;
} //end constructor
public void setProductName(String name) {
productName = name;
}// end set
public String getProductName(){
return productName;
}//end get
public void setItemNumber(double number){
itemNumber = number;
} //end set
public double getItemNumber(){
return itemNumber;
}//end get
public void setInStock(double stock){
inStock = stock;
} //end set
public double getInStock(){
return inStock;
}//end get
public void setItemPrice(double price){
itemPrice = price;
} //end set
public double getItemPrice(){
return itemPrice;
}//end get
//inventory value calculation
public double value(){
return itemPrice * inStock;
}//end value calculation
}// end class