Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

ferrari class in java

public class Ferrari extends Car{
    private String engineType = "Electric";
    private String gear = "manual";
    private int maxSpeed = 340;
    public Ferrari( int cylinder, int speed,String engineType, String gear) {
        super(false, "prestigious 1:8 scale model ",
                2, cylinder, 2, speed, 340);
        this.engineType = engineType;
        this.gear = gear;
    }

    public void setEngineType(String engineType) {
        this.engineType = engineType;
    }

    public void setGear(String gear) {
        this.gear = gear;

    }

    @Override
    public String getModel() {
        return super.getModel();
    }

    @Override
    public void stopEngine(){
        super.stopEngine();
    }
    @Override
    public void startEngine(){
        super.startEngine();
    }

    @Override
    public int Accelerate(int acceleration,int maxSpeed) {
        int speed = 0;
        speed += acceleration;
        if(getSpeed()+acceleration > 340)
        {
            System.out.println("Your Ferrari SF90 exceeds the limit "+this.maxSpeed);
        }else if( acceleration <=0)
        {
            System.out.println("Invalid speed for acceleration ");
        }super.Accelerate(acceleration,this.maxSpeed);
        return getSpeed();
    }

    public int getMaxSpeed() {
        return maxSpeed;
    }

    @Override
    public void setSpeed(int speed,int maxSpeed) {
        maxSpeed = this.maxSpeed;
        super.setSpeed(speed,maxSpeed);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java 001 
Java :: encode é to é java 
Java :: hibernate getList of a table 
Java :: spring boot rest api 
Java :: change FS to hdfs java 
Java :: exmple of methods in java 
Java :: chemistry formula on android 
Java :: apache poi excel color 
Java :: how to do 4th root java 
Java :: find the length of jtextfeild in java 
Java :: Access Members of a Class Java 
Java :: How to adjust layout when soft keyboard appears 
Java :: choose image java 
Java :: getter and setter in java 
Java :: setting up javafx in eclipse 
Java :: java define interface 
Java :: findview by id in android 
Java :: class syntax in java 
Java :: what is operator overloading in java 
Java :: java @override 
Java :: java how to write something on the console with scanner 
Java :: get the logged in user java 
Java :: java button with jpg image 
Java :: how do I test the reverse method in java using jest 
Java :: in java write a code that suppose the following input is supplied to the program: 9 Then, the output should be: 12096 (99+999+9999+999) 
Sql :: oracle nls_date_format 
Sql :: alter table add column boolean 
Sql :: uninstall mysql on ubuntu 
Sql :: see all databases mysql 
Sql :: install mysql ubuntu 18.04 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =