48 lines
805 B
Java
48 lines
805 B
Java
/*
|
|
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
|
|
* Date: 2022/04/03
|
|
* Description: This is the abstract class of Bird.
|
|
* The Airplane class implements the Flyer interface.
|
|
*/
|
|
|
|
public class Airplane implements Flyer {
|
|
private String name;
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param name
|
|
*/
|
|
public Airplane(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
/**
|
|
* Get the name of the airplane.
|
|
*
|
|
* @return name
|
|
*/
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
/**
|
|
* Whether the airplane can fly.
|
|
*
|
|
* @return true
|
|
*/
|
|
public boolean canFly() {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Test.
|
|
*/
|
|
public static void testAirplane() {
|
|
Airplane airplane = new Airplane("Airbus A380");
|
|
System.out.println(airplane.getName() == "Airbus A380");
|
|
System.out.println(airplane.canFly() == true);
|
|
}
|
|
|
|
}
|