航班订票系统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.pluginsorg.eclipse.core.resources
     目录           0  2014-04-23 23:33  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history10
     文件        9459  2014-04-23 09:02  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history10000341683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history15
     文件        4155  2014-04-23 09:02  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history15801a3a1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history17
     文件        4388  2014-04-23 09:02  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history17c0983f1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:05  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history18
     文件        1900  2014-04-23 09:04  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history18f0dfb55083ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history19
     文件        6051  2014-04-23 09:02  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history19e0043b1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:12  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history1f
     文件        7280  2014-04-23 09:12  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history1fe0f5134b84ca0013141c84e633bfb104
     目录           0  2014-04-23 09:48  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history26
     文件        4490  2014-04-23 09:27  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history2660f94d6089ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history27
     文件        4252  2014-04-23 09:02  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history2701e381683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:48  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history2a
     文件        1881  2014-04-23 09:34  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history2a80b8506089ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history37
     文件        6253  2014-04-23 09:01  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history37900c2e1683ca0013141c84e633bfb104
     目录           0  2014-04-23 09:27  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history3c
     文件        4497  2014-04-23 09:23  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history3c205ed96c86ca0013141c84e633bfb104
     目录           0  2014-04-23 09:05  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history6c
     文件        4388  2014-04-23 09:04  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history6ce06ab65283ca0013141c84e633bfb104
     目录           0  2014-04-23 09:03  航班系统(java).metadata.pluginsorg.eclipse.core.resources.history77
............此处省略531个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)