chapter13n2.java
来自「JAVA源代码程序aashjkjhkjhkjhjkhkj」· Java 代码 · 共 36 行
JAVA
36 行
/** * 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 + =
减小字号Ctrl + -
显示快捷键?