flight.java

来自「老师给的在线航班系统」· Java 代码 · 共 79 行

JAVA
79
字号
package com.toa.abs.model;

import java.util.Calendar;



/**
 * 航班类型,用来描述在某个确定日期执行某个定期航班计划的一次航班。
 * 例如:2007年5月25日从北京飞上海的CA1202就是一个航班的实例。
 * @author tangliang
 *
 */
public final class Flight implements java.io.Serializable{
	private FlightScheduler sch;//航班计划
	private Calendar date;//航班日期
	private int[] remainSeats;//各舱位剩余座位数
	private double priceOff;//折扣
	
	Flight(FlightScheduler sch,Calendar date,double priceOff) {
		this.remainSeats=new int[3];
		this.remainSeats[0]=sch.getPlane().getFCS();
		this.remainSeats[1]=sch.getPlane().getBCS();
		this.remainSeats[2]=sch.getPlane().getECS();
		this.date = date;
		this.sch = sch;
		this.priceOff = priceOff;
	}
	
	/**
	 * 覆盖equals()方法。
	 */
	public boolean equals(Object o){
		if(o instanceof Flight){
			Flight f=(Flight)o;
			return (f.sch.equals(this.sch) && 
					f.date.equals(this.date));
		}
		return false;
	}
	
	/**
	 * 覆盖hashCode()方法。
	 */
	public int hashCode(){
		return this.date.hashCode()^this.sch.hashCode(); 
	}

	public Calendar getDate() {
		return date;
	}

	public FlightScheduler getSch() {
		return sch;
	}

	public double getPriceOff() {
		return priceOff;
	}

	public int getFCSRemain(){
		return remainSeats[0];
	}
	public int getBCSRemain(){
		return remainSeats[1];
	}
	public int getECSRemain(){
		return remainSeats[2];
	}
	public void setFCSRemain(int a){
		 remainSeats[0]=a;
	}
	public void setBCSRemain(int a){
		remainSeats[1]=a;
	}
	public void setECSRemain(int a){
		remainSeats[2]=a;
	}
}

⌨️ 快捷键说明

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