Files
oop/lab/lab7/Question9/Airplane.java
2022-04-03 15:15:13 +08:00

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;
}
}