Create an abstract class named Equipment that holds fields for: a numeric equipm
ID: 3581478 • Letter: C
Question
Create an abstract class named Equipment that holds fields for: a numeric equipment type, a String equipment name, and a fee for renting the equipment. Include a final array that holds the equipment names—jet ski, pontoon boat, rowboat, canoe, kayak, beach chair, umbrella, and other. Also include a final array that includes the surcharges for each equipment type— $50, $40, $15, $12, $10, $2, $1, and $0, respectively. Include a constructor that requires an equipment type (assume the user will enter a valid number). Include get and set methods for each field, and include an abstract method that returns a String explaining the lesson policy for the type of equipment. Save the file as Equipment.java.
Explanation / Answer
Equipment.java
public abstract class Equipment {
private int equipmentType;
private String equipmentName;
final String equipmentNames[] = {"jet ski", "pontoon boat", "rowboat", "canoe", "kayak", "beach chair", "umbrella","other"};
final int equipmentTypes[] = {50, 40, 15, 12, 10, 2, 1, 0};
private double fee;
public Equipment(int equipmentType){
this.equipmentType = equipmentType;
}
abstract String lessonPolicy();
public int getEquipmentType() {
return equipmentType;
}
public void setEquipmentType(int equipmentType) {
this.equipmentType = equipmentType;
}
public String getEquipmentName() {
return equipmentName;
}
public void setEquipmentName(String equipmentName) {
this.equipmentName = equipmentName;
}
public double getFee() {
return fee;
}
public void setFee(double fee) {
this.fee = fee;
}
public String[] getEquipmentNames() {
return equipmentNames;
}
public int[] getEquipmentTypes() {
return equipmentTypes;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.