Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Cars {
- private String brand;
- private int nbSeats;
- private int nbDoors;
- private int speed;
- private String color;
- private Engine engine;
- public Car(String brand, int nbSeats, int nbDoors, int speed, String color, Engine engine)
- {
- this.brand = brand;
- this.nbSeats = nbSeats;
- this.nbDoors = nbDoors;
- this.speed = speed;
- this.color=color;
- this.engine=engine;
- }
- public String toString(){
- return this.brand + this.nbSeats+ this.nbDoors +this.speed+ this.engine;
- }
- }
- class Engine {
- private int power;
- private int maxTorque;
- public Engine(double power, int maxTorque){
- this.power=power;
- this.maxTorque= maxTorque;
- }
- public String toString(){
- return " "+ this.power + this.maxTorque;
- }
- }
- class PetrolEngine extends Engine{
- private boolean hasCat;
- public PetrolEngine(int maxTorque, int power, boolean hasCat){
- super(maxTorque,power);
- this.hasCat=hasCat;
- }
- public boolean hasCatalyst(){
- return this.hasCat;
- }
- }
- class DieselEngine extends Engine{
- public String toString(){
- return "Diesel engine";
- }
- }
- class SUV extends Cars{
- private boolean suv4x4;
- private boolean gndClearance = true;
- public boolean is4x4(){
- return this.suv4x4;
- }
- }
- class NormalCars extends Cars{
- public String toString(){
- return "Normal car";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement