[ create a new paste ] login | about

Link: http://codepad.org/CmWplVyc    [ raw code | fork ]

Plain Text, pasted on Apr 22:
public class Part implements Comparable
{
	// attributes
	private String partNumber; 
	private String description; 
	private double price; 
	private String warehouseID; 
	private int quantity;
	
	// Parameterized Constructor
	public Part(String partNumber,
			String description, double price,
			String warehouseID, int quantity)
	{
		super();
		this.partNumber = partNumber;
		this.description = description;
		this.price = price;
		this.warehouseID = warehouseID;
		this.quantity = quantity;
	}
	
	// Getters
	public String getPartNumber()
	{
		return partNumber;
	}

	public String getDescription()
	{
		return description;
	}

	public double getPrice()
	{
		return price;
	}

	public String getWarehouseID()
	{
		return warehouseID;
	}

	public int getQuantity()
	{
		return quantity;
	} 
	
	// The use of the comparable interface
	public int compareTo(Object argument)
	{
		if (this.price > ((Part)argument).price )
		{
			return 1; 
		}
		else if ( this.price == ((Part)argument).price)
		{
			return 0; 
		}
		else 
		{
			return -1; 
		}
	}
	/*
	 * 
	 */
	public int getTotalQuantity()
	{
		int total = 0; 
		for( int i = 0; i < ) 
		return total;
	}
}


Create a new paste based on this one


Comments: