📄 chapter13n2.java
字号:
/** * demonstration of Polymorphism */public class Chapter13n2 { public static void main(String[] args) { Reservation[] collection = new Reservation[4] ; BasicReservation br = new BasicReservation() ; br.set(12, 23) ; collection[0] = br ; NiceReservation nr1 = new NiceReservation() ; nr1.set(34, 45, NiceReservation.AISLE, NiceReservation.GREEN) ; collection[1] = nr1 ; NiceReservation nr2 = new NiceReservation() ; nr2.set(45, 56, NiceReservation.WINDOW, NiceReservation.RED) ; collection[2] = nr2 ; PoshReservation pr = new PoshReservation() ; pr.set(67, 78, NiceReservation.AISLE, NiceReservation.WHITE, "Motherwell") ; collection[3] = pr ; for (int i = 0 ; i < 4 ; i++) { collection[i].print() ; System.out.println() ; } } // end of main method } // end of class Chapter13n2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -