Java Class
Java is a programming language that can be sometimes be tedious if you don’t have an idea on how to create parent-child classes. Here it is a very example to follow:

class Plane {
    protected double size = 5;
    protected double weight;
    protected int age;
    protected double cost;
    protected double maxSpeed;
    public void fly() {
        System.out.print("I'm flying and");
    }
}

class Glider extends Plane {
    protected double maxAltitude;
    protected double amountOfWindNeeded;
    public void fly() {
        System.out.print("I'm a Glider \n");
    }
}

class PropPlane extends Plane {
    protected String typeOfFuel;
    protected int numberOfProps;
    public void fly() {
        System.out.print("I'm a Prop Plane \n");
    }
}

class Jet extends Plane {
    protected String typeOfFuel;
    protected double minimumSpeed;
    public void fly() {
        System.out.print("I'm a Jet \n");
    }
}

class Main{
    public static void main(String[] args) {
        
        Plane plane = new Plane();
        Glider gl = new Glider();
        PropPlane pl = new PropPlane();
        Jet jt = new Jet();
        
        plane.fly(); gl.fly();
        plane.fly(); pl.fly();
        plane.fly(); jt.fly();
    }
}

That is it!. Bye-Bye 🙂

Leave a Reply

Back to Top