ferrari class in java

Solutions on MaxInterview for ferrari class in java by the best coders in the world

showing results for - "ferrari class in java"
Alessio
23 Jun 2017
1public class Ferrari extends Car{
2    private String engineType = "Electric";
3    private String gear = "manual";
4    private int maxSpeed = 340;
5    public Ferrari( int cylinder, int speed,String engineType, String gear) {
6        super(false, "prestigious 1:8 scale model ",
7                2, cylinder, 2, speed, 340);
8        this.engineType = engineType;
9        this.gear = gear;
10    }
11
12    public void setEngineType(String engineType) {
13        this.engineType = engineType;
14    }
15
16    public void setGear(String gear) {
17        this.gear = gear;
18
19    }
20
21    @Override
22    public String getModel() {
23        return super.getModel();
24    }
25
26    @Override
27    public void stopEngine(){
28        super.stopEngine();
29    }
30    @Override
31    public void startEngine(){
32        super.startEngine();
33    }
34
35    @Override
36    public int Accelerate(int acceleration,int maxSpeed) {
37        int speed = 0;
38        speed += acceleration;
39        if(getSpeed()+acceleration > 340)
40        {
41            System.out.println("Your Ferrari SF90 exceeds the limit "+this.maxSpeed);
42        }else if( acceleration <=0)
43        {
44            System.out.println("Invalid speed for acceleration ");
45        }super.Accelerate(acceleration,this.maxSpeed);
46        return getSpeed();
47    }
48
49    public int getMaxSpeed() {
50        return maxSpeed;
51    }
52
53    @Override
54    public void setSpeed(int speed,int maxSpeed) {
55        maxSpeed = this.maxSpeed;
56        super.setSpeed(speed,maxSpeed);
57    }
58}
59
queries leading to this page
ferrari class in javaferrari class in java