Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Inventory system Test program help.

$
0
0
Hello all, I am new to the world of Java. I have a homework assignment to build a class that handles an inventory system. It stores an integer of how many items are on hand and their price. The class handles adding items, subtracting items, returning the value of the quantity on hand, and returning the quantity on hand. I have written what seems to be a good class. It compiles with no error messages. I am trying to find information on how to build a test program to test it. I just don't know where to go from here and it's getting quite frustrating to get an answer from anyone. Any help? Here is my class code.

public class Inventory {


	//Declare data members
	private int quantity;
	private double cost;
	int quant;
	
	//Set Default Constructor
	public Inventory()
	{
		quantity = 0;
		cost = 0.0;
	}
	
	//Set Constructor w/ parameters
	public Inventory(int quant, double price)
	{
		
		quantity = quant;
		cost = price;
	}
	
	//To add the items
	
	public void addItems(int newItems)
	{
		quantity = quant + newItems;
	}
	
	//To delete items
	
	public void deleteItems(int oldItems)
	{
		quantity = quant - oldItems;
	}
	
	//To set the cost
	
	public void setCost(int newCost)
	{
		cost = newCost;
	}
	
	//To return value of quantity
	public double ReturnValue()
	{
		double Value = quantity * cost;
		return Value;		
	}
	
	//To return the quantity on hand
	public int ReturnQuantity ()
	{
		return quantity;
	}
	
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles