日期:2014-05-20  浏览次数:20627 次

新的问题,eclipse·暂时不会调试
问题是:增加路线那个地方总是不行,则呢么该?

package mypackage.booksystem;
import java.util.*;
class Ticket{
protected String trainNum;  //班次
protected String date; //日期
protected String startCity; //起点
protected String toCity; //终点
protected String startTime; //起始时间
protected String toTime; //到达时间
protected int seatAmount; //座位数量
protected double ticketPrice; //票价
private static int linesAmount = 0; //路线数量
protected static Ticket ticket0 = incTicket(); //当前已有航线0
protected static Ticket ticket1 = incTicket();//当前已有航线1
private static ArrayList<Ticket> tickets = new  ArrayList<Ticket>(Ticket.linesAmount + 1);

public Ticket(){} //构建一个 Ticket 对象

public static Ticket incTicket(){ //增加路线
linesAmount++;
return new Ticket();
}

public static void assignInfoForTicket(Ticket ticket){
Ticket.tickets.add(ticket);
ticket.setTrainInfo("K222", "Hefei", "Shanghai", "08/23", "09:20", "10:20", 50, 50.0);
}

/* public static Ticket decTicket(){linesAmount--;return null;} */ //删除路线

public String getTrainNum(){return this.trainNum;}
public String getStartCity(){return this.startCity;}
public String getToCity(){return this.toCity;}
public String getDate(){return this.date;}
public String getStartTime(){return this.startTime;}
public String getToTime(){return this.toTime;}
public int getSeatAmount(){return this.seatAmount;}
public double getTicketPrice(){return this.ticketPrice;}
public static ArrayList<Ticket> getTickets(){return tickets;} 
public static int getLinesAmount(){return linesAmount;}

public void setTrainInfo(String tN,String sC, String tC, String d, String sT, String tT, int sA, double tP){
this.trainNum = tN;
this.startCity = sC;
this.toCity = tC;
this.date = d;
this.startTime = sT;
this.toTime = tT;
this.seatAmount = sA;
this.ticketPrice = tP;
}

public static void printHead(){
System.out.printf("%10s%9s%14s%14s%10s%10s%7s%11s\n", 
"班   次","日   期","始   发   站","终   点   站","始发时间","到达时间","座位量","票      价");