58 lines
975 B
Java
58 lines
975 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());
|
|
System.out.println(airplane.isDangerous() == false);
|
|
}
|
|
|
|
/**
|
|
* Wheterh the object is dangerous.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public boolean isDangerous() {
|
|
return false;
|
|
}
|
|
|
|
}
|