?? sandwich8.java
字號(hào):
// interfaces/Sandwich8.java
// TIJ4 Chapter Interfaces, Exercise 8, page 320
/* In polymorphism.Sandwich.java, create an interface called FastFood (with
* appropriate methods) and change Sandwich so that it also implements
* FastFood.
*/
package interfaces;
import static net.mindview.util.Print.*;
interface FastFood {
void cheeseburger();
void fries();
void softDrink();
}
class Meal {
Meal() { print("Meal()"); }
}
class Bread {
Bread() { print("Bread()"); }
}
class Cheese {
Cheese() { print("Cheese()"); }
}
class Lettuce {
Lettuce() { print("Lettuce()"); }
}
class Lunch extends Meal {
Lunch() { print("Lunch()"); }
}
class PortableLunch extends Lunch {
PortableLunch() { print("PortableLunch()"); }
}
public class Sandwich8 extends PortableLunch implements FastFood {
private Bread b = new Bread();
private Cheese c = new Cheese();
private Lunch l = new Lunch();
public Sandwich8() { print("Sandwich8()"); }
public void cheeseburger() {
print("Cheeseburger");
}
public void fries() {
print("Fries");
}
public void softDrink(){
print("Soft Drink");
}
public static void main(String[] args) {
Sandwich8 s = new Sandwich8();
s.cheeseburger();
s.fries();
s.softDrink();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -