⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter13n1.java

📁 JAVA源代码程序aashjkjhkjhkjhjkhkj
💻 JAVA
字号:
// print/** * models three different types of flight reservation */import java.io.* ;import java.lancs.* ;import java.util.* ;class Reservation    {    private int flightNumber ;    private Date dateOfTravel ;    private int seatNumber ;    public void set(int fn, int sn)	{	flightNumber = fn ;	seatNumber = sn ;	} // end of method set    public void read() throws IOException	{	BasicIo.prompt("Flight number?: ") ;	flightNumber = BasicIo.readInteger() ;	BasicIo.prompt("Seat number?: ") ;	seatNumber = BasicIo.readInteger() ;	} // end of method read    public void print()	{	System.out.println("Flight Number: " + flightNumber) ;	System.out.println("Seat Number: " + seatNumber) ;	} // end of method print    public String toString()	{	return "flight " + flightNumber + ": seat " + seatNumber ;	} // end of method toString    } // end of class Reservationclass BasicReservation extends Reservation    {    } // end of class BasicReservationclass NiceReservation extends Reservation    {    public static final int AISLE = 1, WINDOW = 2 ;    public static final int GREEN = 1, WHITE = 2, RED = 3 ;    private int seatSort ;    private int food ;    public void set(int fn, int sn, int st, int f)	{	super.set(fn, sn) ;	seatSort = st ;	food = f ;	} // end of method set    public void read() throws IOException	{	super.read() ;		// call read method belonging to				// superclass - in this case				// Reservation.read	BasicIo.prompt("kind of food? 1 (green), 2 (white), 3 (red): ") ;	food = BasicIo.readInteger() ;	BasicIo.prompt("kind of seat? 1 (aisle), 2 (window): ") ;	seatSort = BasicIo.readInteger() ;	} // end of method read    public void print()	{	super.print() ;	System.out.println("Type of Seat: " + seatSort) ;	System.out.println("Type of Food: " + food) ;	} // end of method print    public String toString()	{	return super.toString() + ": sort " + seatSort + ": food " + food ;	} // end of method toString    } // end of class NiceReservationclass PoshReservation extends NiceReservation    {    private String destination ;    public void set(int fn, int sn, int st, int f, String d)	{	super.set(fn, sn, st, f) ;	destination = d ;	} // end of method set    public void read() throws IOException	{	super.read() ;		// call read method belonging to				// superclass - in this case				// NiceReservation.read	BasicIo.prompt("Destination address?: ") ;	destination = BasicIo.readString() ;	} // end of method read    public void print()	{	super.print() ;	System.out.println("Destination address: " + destination) ;	} // end of method print    public String toString()	{	return super.toString() + ": destination " + destination ;	} // end of method toString    } // end of class PoshReservation    public class Chapter13n1    {    public static void main(String[] args) throws IOException	{	System.out.println("res1: Basic") ;	BasicReservation res1 = new BasicReservation() ;	res1.read() ;	System.out.println("Basic Reservation is " + res1) ;	System.out.println() ;	System.out.println("res2: Nice") ;	NiceReservation res2 = new NiceReservation() ;	res2.read() ;	System.out.println("Nice Reservation is " + res2) ;	System.out.println() ;	System.out.println("res3: Posh") ;	PoshReservation res3 = new PoshReservation() ;	res3.read() ;	System.out.println("Posh Reservation is " + res3) ;	} // end of main method    } // end of class Chapter13n1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -