資源描述:
《電影院售票系統(tǒng)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、packageticket.entity;importjava.io.FilelnputStream;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io」OException;importjava.io.Objectinputstream;importjava.io.ObjectOutputStream;importjava.util.ArrayList;importjava.util.List;/**電影院類*/publicclassCinam
2、e{publicScheduleschedule;publicScheduleitemscheduleitem;publicSeatseat;publicListsoldTickets=null;publicListseatlist=newArrayList();〃初始化座位衣publicListinitializeSeat(){forfinti=l;i<=5;i++){for(intj=l;j<=7;j++){seatlist.addfnewSeat(i+"-"+j));}}returnseatlis
3、t;}〃初始化電影栗,并序列化到本地保存〃保存銷售情況publicstaticvoidsave(ListsoldTickets){ObjectOutputStream(newtry{ObjectOutputstreamoos=newFileOutputStream("D:/myTest/sale.dll"));oos.writeObject(soldTickets);oos.close();}catch(FileNotFoundExceptione){e.printStackTrace();}catch(lOExceptione){e.p
4、rintStackTrace();}〃讀取銷售情況@SuppressWarnings(”unchecked")publicvoidload(){Objectinputstreamois二null;try{ois二newObjectlnputStream(newFilelnputStream("D:/myTest/sale.dll"));if(ois.available()!=-l){soldTickets=(List)ois.readObject();訐(!soldTickets.isEmpty()){System.out.println
5、C'今日售票明細:");System.out.pri);System.out.printlnC*影片:”+”非常完美”+”t場次:”+”09:00”);System.out.println(”");System.out.printlnC'座位號:");intcount=0;for(inti=l;i<=5;i++){for(intj=l;j<=7;j++){booleanisSold二false;forfintx=0;x6、).equals("09:00")){if(soldTickets.get(x).seat.getSeatNum().equals(i+"-"+j)){System.out.print(i+"-"+j+n[售]");count+=l;isSold=true;break;}}}if(!isSold){System.out.print(i+"-"+j+,,[空]”);}if(j=7)System.out.println();}}System.out.printlnC本場電影售出票數(shù):H+count);System.out.println(”");System
7、.out.printlnC'影片:H+"非常完美”+”t場次:“+”13:00“);System.out.println(”");count=0;for(inti=l;i<=5;i++){for(intj=l;j<=7;j++){booleanisSold二false;for(intx=0;x8、s(i+"-"+j)){System.out.print(i+"-"+j+,,[