Answer to Question #297544 in Java | JSP | JSF for rainbow

Question #297544

Appliance and TV

by CodeChum Admin

Create a class called Appliance. An appliance simply has a:

  • brand (a text)
  • a cost (a monetary value)
  • a power status (ON or OFF)

Power status, brand and cost should not be accessible out the class or its hierarchy of inheritance


1
Expert's answer
2022-02-14T12:04:29-0500


class Appliance {
	private String brand;// (a text)
	private double cost;// (a monetary value)
	private boolean powerStatus;// (ON or OFF)


	public Appliance() {
	}


	public Appliance(String brand, double cost, boolean powerStatus) {
		this.brand = brand;
		this.cost = cost;
		this.powerStatus = powerStatus;
	}


	/**
	 * @return the brand
	 */
	public String getBrand() {
		return brand;
	}


	/**
	 * @param brand the brand to set
	 */
	public void setBrand(String brand) {
		this.brand = brand;
	}


	/**
	 * @return the cost
	 */
	public double getCost() {
		return cost;
	}


	/**
	 * @param cost the cost to set
	 */
	public void setCost(double cost) {
		this.cost = cost;
	}


	/**
	 * @return the powerStatus
	 */
	public boolean isPowerStatus() {
		return powerStatus;
	}


	/**
	 * @param powerStatus the powerStatus to set
	 */
	public void setPowerStatus(boolean powerStatus) {
		this.powerStatus = powerStatus;
	}


}


class TV extends Appliance {


	public TV() {
	}


	public TV(String brand, double cost, boolean powerStatus) {
		super(brand, cost, powerStatus);
	}
}


class App {


	public static void main(String[] args) {


	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS