⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fflylist.java

📁 用JAVA写的航班信息管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
             }
             swapReferences( sl, i, right - 1 );   

             SortQuick(fun, left, i - 1 );    
             SortQuick(fun, i + 1, right );  
         }
         else  
        	 SortAbsSwap(fun, left, right );
     }
     
     void SortAbsSwap(String fun)
     {
    	SortAbsSwap(fun, 1, length-1); 
     }
     
      void SortAbsSwap(String fun, int left, int right )
     {
         for( int p = left + 1; p <= right; p++ )
         {
        	 InfoType tmp = sl[ p ];
             int j;

             for( j = p; j > left && tmp.compareTo(fun, sl[ j - 1 ] ) < 0; j-- )
                 sl[ j ] = sl[ j - 1 ];
             sl[ j ] = tmp;
         }
     }
      
      String Find(String fun, String key) {
		int dw=0;
		String ss=GetTitle();
		for(int i=length-1;i>0;i--)
			if(sl[i].equals(fun,key))
			{
				dw=i;
				ss+=sl[i].GetOne();
			}
		if(dw==0)
			return("0"); 
		return(ss); 
	}
}

class planesystem extends JFrame{
	private SLList hbb=new SLList();
	Container cg;
	JPanel total[]=new JPanel[20];
	JTextArea t[]=new JTextArea[10];
	JLabel l[]=new JLabel[10];
	WindowDestroyer myListener=new WindowDestroyer();
	JButton b[]=new JButton[2];
	
	public planesystem(){
		super();
		readfile();
		for(int i=0; i<total.length; i++)
			total[i]=new JPanel();
		for(int i=0; i<t.length; i++)
			t[i]=new JTextArea();
		for(int i=0; i<l.length; i++)
			l[i]=new JLabel();
		for(int i=0;i<2;i++)
			b[i]=new JButton();
		setTitle("航班信息查询系统");
		setSize(800,600);
		setLocation(0,0);
		addWindowListener(myListener);
		cg=getContentPane();
		cg.setLayout(new GridLayout(1,1));
		menu();
		total[0].setBackground(Color.BLUE);
		total[0].setLayout(new BorderLayout());
		cg.add(total[0]);
		Font b=new Font("隶书",Font.BOLD,48);
		l[0].setText("欢迎使用航班信息查询系统");
		l[0].setFont(b);
		l[0].setForeground(Color.YELLOW);
		total[0].add(l[0],"Center");
	}
	
	public void menu(){
		JMenuBar mb=new JMenuBar();
		setJMenuBar(mb);
		String mainmenutitle[]={"显示","排序","查询","帮助"};
		JMenu mainm[]=new JMenu[4];
		for(int i=0; i<mainmenutitle.length; i++)
		{
			mainm[i]=new JMenu(mainmenutitle[i]);
			mb.add(mainm[i]);
		}
		JMenuItem m[][]=new JMenuItem[4][7];
		int k=0;
		String menutitle[]={"按航班号排序显示","按起点站排序显示","按终点站排序显示","按起飞时间排序显示","按到达时间排序显示","按机型排序显示","按价格排序显示",
				"直接插入排序","希尔排序","冒泡排序","快速排序","直接选择排序","大根堆排序","归并排序",
				"按航班号查询","按起点站查询","按终点站查询","按起飞时间查询","按到达时间查询","按日期查询","按价格查询",
				"版本信息"};
		Action action[]=new Action[40];
		for(int i=0; i<m.length; i++)
		{
			for(int j=0; j<m[i].length; j++)
			{
				if(i==0&&j==3||i==0&&j==5||i==1&&j==2||i==1&&j==4||i==2&&j==3||i==2&&j==5)
				{
					mainm[i].add(new JSeparator());
				}
				if(i==3&&j>=1)
					continue;
				//System.out.println(i+" "+j+" "+k);
				m[i][j]=new JMenuItem(menutitle[k]);
				mainm[i].add(m[i][j]);
				action[k]=new Action(k);
				m[i][j].addActionListener(action[k]);
				k++;
			}
		}
	}
	
	class Action implements ActionListener{
		int k;
		Action(int k)
		{
			this.k=k;
		}
		
	    public void actionPerformed(ActionEvent e){
			l[0].setText("sadf");
	    	for(int i=0;i<total.length;i++)
	    	{
	    		if(cg.isAncestorOf(total[i]))
	    		{
	    			System.out.println(i);
	    			cg.remove(total[i]);
	    		}
	    	}
	    	//l[1].setText("sadf");
	    	//cg.add(l[1]);
			switch(k)
			{
			case 0:
				hbb.SortAbsInsert("hbh");
				showinformation();
				break;
			case 1:
				hbb.SortAbsInsert("start");
				showinformation();
				break;
			case 2:
				hbb.SortAbsInsert("end");
				showinformation();
				break;
			case 3:
				hbb.SortAbsInsert("time1");
				showinformation();
				break;
			case 4:
				hbb.SortAbsInsert("time2");
				showinformation();
				break;
			case 5:
				hbb.SortAbsInsert("model");
				showinformation();
				break;
			case 6:
				hbb.SortAbsInsert("price");
				showinformation();
				break;
			case 7:
				hbb.SortAbsInsert("hbh");
				showinformation();
				break;
			case 8:
				hbb.SortShell("hbh");
				showinformation();
				break;
			case 9:
				hbb.SortBubble("hbh");
				showinformation();
				break;
			case 10:
				hbb.SortQuick("hbh");
				showinformation();
				break;
			case 11:
				hbb.SortAbsSwap("hbh");
				showinformation();
				break;
			case 12:
				hbb.SortByTree("hbh");
				showinformation();
				break;
			case 13:
				hbb.SortMerge("hbh");
				showinformation();
				break;
			case 14:
				showfind("hbh");
				break;
			case 15:
				showfind("start");
				break;
			case 16:
				showfind("end");
				break;
			case 17:
				showfind("time1");
				break;
			case 18:
				showfind("time2");
				break;
			case 19:
				showfind("date");
				break;
			case 20:
				showfind("price");
				break;
			case 21:
				showversion();
				break;
			}
		}
	}

	public void showinformation(){
		total[1].setLayout(new GridLayout(1,1));
		cg.add(total[1]);
		String ss=hbb.GetTotal();
		t[0].setText(ss);
		total[1].add(t[0]);
	}
	
	public void showversion(){
		total[1].setLayout(new GridLayout(1,1));
		cg.add(total[1]);
		String ss=hbb.GetTotal();
		t[0].setText(ss);
		total[1].add(t[0]);
		JOptionPane.showMessageDialog(cg,"版本号:V2.0\n完成日期:2006年6月27日","版本信息",JOptionPane.INFORMATION_MESSAGE);
	}
	
	public void showfind(String fun){
		total[1].setLayout(new GridLayout(1,1));
		cg.add(total[1]);
		t[0].setText("");
		total[1].add(t[0]);
		String s="";
		if (fun.equals("hbh"))
			s="航班号";
		else if (fun.equals("start"))
			s="起点站";
		else if (fun.equals("end"))
			s="终点站";
		else if (fun.equals("time1"))
			s="起飞时间";
		else if (fun.equals("time2"))
			s="到达时间";
		else if (fun.equals("data"))
			s="日期(YYYYMMDD,如“20060620”)";
		else if (fun.equals("price"))
			s="票价";
		else if (fun.equals("date"))
			s="日期";
		String aa=JOptionPane.showInputDialog("请输入需查询的"+s+":");
		String ss=hbb.Find(fun, aa);
		if(ss.equals("0"))
			ss="没有对应信息!";
		t[0].setText(ss);
	}
	
	public void readfile(){
		try{
			FileReader wb=new FileReader("航班列表.txt");
			BufferedReader in=new BufferedReader(wb);
			String str;
			str=in.readLine();
			while(str!=null){
				hbb.fileappend(str);
				str=in.readLine();
			}
			in.close();
		}catch(Exception x){}
	}
	
	public void showinformationverison(){
		setTitle("版本信息目录");
		setSize(800,600);
		setLocation(0,0);
		WindowDestroyer myListener=new WindowDestroyer();
		addWindowListener(myListener);
		Container ct;
		ct=getContentPane();
		ct.setLayout(new GridLayout());
		menu();
		JTextArea t10=new JTextArea();
		try{
			FileReader wb=new FileReader("版本信息.txt");
			BufferedReader in=new BufferedReader(wb);
			String str;
			str=in.readLine();
			t10.setText("");
			while(str!=null){
				t10.append(str+"\n");
				str=in.readLine();
			}
			in.close();
		}catch(Exception x){}	
		t10.setTabSize(2);
		t10.setEditable(false);
		ct.add(t10);
	}
	
	class WindowDestroyer extends WindowAdapter{
		public void windowClosing(WindowEvent e){
			System.exit(0);
		}
	}
	
	class LabelButton1 implements ActionListener{
		public void actionPerformed(ActionEvent e){
			for(int i=0;i<10;i++)
			{
				t[i].setText(null);
			}
		}
	}
	class LabelButton2 implements ActionListener{
		public void actionPerformed(ActionEvent e){
			try{
			t[8].setText(t[0].getText()+"\t"+t[1].getText()+"\t"+t[2].getText()+"\t"+t[3].getText()+"\t"+t[4].getText()+"\t"+t[5].getText()+"\t"+t[6].getText()+"\t"+t[7].getText());
			String sx=t[7].getText();
			int p=Integer.parseInt(sx);
			
			hbb.append(t[0].getText(),t[1].getText(),t[2].getText(),t[3].getText(),t[4].getText(),t[5].getText(),t[6].getText(),p);
			PrintWriter out=new PrintWriter(new FileOutputStream("航班列表.txt"));
			out.println("");
			out.println(t[0].getText()+"\t"+t[1].getText()+"\t"+t[2].getText()+"\t"+t[3].getText()+"\t"+t[4].getText()+"\t"+t[5].getText()+"\t"+t[6].getText()+"\t"+t[7].getText());
			out.close();
			}catch(Exception t){t.printStackTrace();}
		}
		}
}

public class FFlylist {
	public static void main(String[] args) throws IOException {
		planesystem wint=new planesystem();
		wint.setVisible(true);
	}
}

⌨️ 快捷键说明

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