Answer to Question #282644 in Java | JSP | JSF for طالب

Question #282644

}



Exercise:



Design a Transportation class:



1. Super class included all class instances (CarModel, CarType,



CarName…etc)



2. Subclass calls the superclass and overridden methods of



superclass. (the methods in superclass as you like).



3. Don’t re-define the class instance in the subclass.



4. Modify the overridden method in the subclass.

1
Expert's answer
2021-12-26T09:42:23-0500
public class Transportation extends Car {

    public Transportation(String carModel, String carType, String carName) {
        super(carModel, carType, carName);
    }

    @Override
    public String toString() {
        return "Transportation: " + super.toString();
    }
}


public class Car {
    private String carModel;
    private String carType;
    private String carName;

    public Car(String carModel, String carType, String carName) {
        this.carModel = carModel;
        this.carType = carType;
        this.carName = carName;
    }

    @Override
    public String toString() {
        return carModel + " " + carType + " " + carName;
    }
}

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