All pastes #474726 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-06 23:47 UTC
rendered paste body
//Conner Finlay
//6 May 2007
//HW5
//The class is the super class for the Microwave and Refrigerator class

public class Appliance
{
	//declare variables to be used
	private String color;
	private double price;
	String aString = "";
	
	//sets the constant
	public final static double DEFAULT_PRICE = 0.0;

	static String[] colorArray = {"black", "silver", "white"};
	private String defaultColor = colorArray[0];
	
	/**
	 *Default Constructor
	 *@param color sets the color
	 */
	public Appliance(String color)
	{
		price = DEFAULT_PRICE;
		this.color = color;
	}
	
	/**
	 *Get the color of the appliance
	 *@return the color
	 */
	public String getColor()
	{
		return color;
	}
	
	/**
	 *Get the price of the appliance
	 *@return the price
	 */
	public double getPrice()
	{
		return price;
	}
	
	/**
	 *Set the color of the appliance
	 *@return the color
	 */
	public boolean setColor(String color)
	{
		//checks to make sure that the color is either black/white/silver
		if(!(color.equals("black")) && !(color.equals("white")) && !(color.equals("silver")))
		{
			return false;
		}
		else
		{
			this.color = color;
			return true;
		}
	}
	
	/**
	 *Set the price of the appliance
	 *@return the price
	 */
	public boolean setPrice(double price)
	{
		//checks to make sure that the price is valid
		if(price >= DEFAULT_PRICE)
		{
			this.price = price;
			return true;
		}
		else
		{
			return false;
		}
	}
	
	/**
	 *Convert data to a string
	 *@return string with data on the appliance
	 */
	public String toString()
	{
		aString = " Color: " + this.color + " Price: " + this.price + " ";
		return aString;
	}
}