by CodeChum Admin
Create a class called Appliance. An appliance simply has a:
Power status, brand and cost should not be accessible out the class or its hierarchy of inheritance
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) {
}
}
Comments
Leave a comment