Close: #1 Lab 7
This commit is contained in:
47
lab/lab7/Question8/Airplane.java
Normal file
47
lab/lab7/Question8/Airplane.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user