• 大小: 9.62MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-13
  • 语言: Java
  • 标签: 航班  订票  java  

资源简介

java实现的航班订票系统,带界面,连网络的。

资源截图

代码片段和文件信息

package flight.assist;

import javax.swing.*;
import java.io.*;
import java.sql.*;

public class SeatInfo 
{
private SqlBean sqlBean = new SqlBean();
private RandomAccessFile raf;
private final int FLIGHT_PER_DAY = 10;

public SeatInfo()
{
            File file=new File(“.““data“);
         file.mkdir();
         File f = new File(file“SeatInfo.txt“);           

try
{
raf = new RandomAccessFile(f“rw“);

if (raf.length() == 0)
{
raf.setLength(31 * 4 * FLIGHT_PER_DAY);
for (int i = 0 ; i < 31 * FLIGHT_PER_DAY;i++)
       raf.writeInt(0);
}
}
catch(Exception e)
{
e.printStackTrace();
}

}

public boolean isFull(String flightNumString day)
{
    try
    {
      long index = cacuIndex(day);
    long address = cacuAddr(flightNum);
    long absoluteAddress = index + address;
    
    raf.seek(absoluteAddress);
    int bookedSeats = raf.readInt();
        String sqlString = “select seat from flight where flight=‘“ + flightNum + “‘“;
ResultSet rs = sqlBean.executeQuery(sqlString);

int totalSeats = 0;

while (rs.next())
totalSeats = rs.getInt(1);
if (totalSeats == bookedSeats)
   return true;
else
   return false;
    
    }
    catch(Exception e)
    {
        return false;
    }
}

public int dingPiao(String flightNumString dayint seats)
{
int leftSeats = 0;
try
    {
     long index = cacuIndex(day);
    long address = cacuAddr(flightNum);
    long absoluteAddress = index + address;
    
    raf.seek(absoluteAddress);
    int bookedSeats = raf.readInt();
    
     String sqlString = “select seatweek from flight where flight=‘“ + flightNum + “‘ “;
ResultSet rs = sqlBean.executeQuery(sqlString);

int totalSeats = 0;
String week=““;
while (rs.next())    
    {
    totalSeats = rs.getInt(1);
    week=rs.getString(2);
    }    
    
String c=isAbsence(day);
    int flag=0;
for(int i=0;i {
String w=week.substring(ii+1);
if(c.equals(w)) 
{
flag=1;
break; 
}
}

if(flag==1)
{
leftSeats = totalSeats - bookedSeats;

if (leftSeats >= seats)
{
raf.seek(absoluteAddress);
raf.writeInt(bookedSeats + seats);
return -1;
}
else
    return leftSeats;
}
else
     return -2;
   

    }
    catch(Exception e)
    {
       e.printStackTrace();
    }
    
    return leftSeats;
}

public void tuiPiao(String flightNumString dayint seats)
{
         try
         {
          long index = cacuIndex(day);
    long address = cacuAddr(flightNum);
    long absoluteAddress = index + address;
    
    raf.seek(absoluteAddress);
    int bookedSeats = raf.readInt();
   
    if (bookedSeats < seats)
       JOptionPane.showMe

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-23 09:51  航班系统(java)\
     目录           0  2014-04-23 08:47  航班系统(java)\.metadata\
     文件           0  2014-04-23 08:47  航班系统(java)\.metadata\.lock
     目录           0  2014-04-24 02:05  航班系统(java)\.metadata\.plugins\
     目录           0  2014-04-24 02:05  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\
     目录           0  2014-04-23 23:33  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\10\
     文件        9459  2014-04-23 09:02  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\10\0000341683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\15\
     文件        4155  2014-04-23 09:02  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\15\801a3a1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\17\
     文件        4388  2014-04-23 09:02  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\17\c0983f1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:05  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\18\
     文件        1900  2014-04-23 09:04  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\18\f0dfb55083ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\19\
     文件        6051  2014-04-23 09:02  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\19\e0043b1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:12  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\1f\
     文件        7280  2014-04-23 09:12  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\1f\e0f5134b84ca0013141c84e633bfb104
     目录           0  2014-04-23 09:48  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\26\
     文件        4490  2014-04-23 09:27  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\26\60f94d6089ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\27\
     文件        4252  2014-04-23 09:02  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\27\b01e381683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:48  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\2a\
     文件        1881  2014-04-23 09:34  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\2a\80b8506089ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\37\
     文件        6253  2014-04-23 09:01  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\37\900c2e1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:27  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\3c\
     文件        4497  2014-04-23 09:23  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\3c\205ed96c86ca0013141c84e633bfb104
     目录           0  2014-04-23 09:05  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\6c\
     文件        4388  2014-04-23 09:04  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\6c\e06ab65283ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java)\.metadata\.plugins\org.eclipse.core.resources\.history\77\
............此处省略531个文件信息

评论

共有 条评论