In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces java how to achieve flight information query management system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Air Infomation System console-based flight information system, referred to as AIS
The specific requirements are as follows:
(1) display the main menu of the flight information system, as shown in the figure, including:
1) list all flights
2) query by departure time
3) query by destination
4), delete the flight
5), update flights
6), exit the system
AirInfo.java
Public class AirInfo {/ * flight number (id) flight number (flight_number) destination (destination) departure date (flight_date) * / private int id; private String flight_number; private String destination; private String flight_date; public AirInfo (int id, String flight_number, String destination, String flight_date) {this.id=id; this.flight_number=flight_number; this.destination=destination; this.flight_date=flight_date;} public int getId () {return id } public void setId (int id) {this.id = id;} public String getFlight_number () {return flight_number;} public void setFlight_number (String flight_number) {this.flight_number = flight_number;} public String getDestination () {return destination;} public void setDestination (String destination) {this.destination = destination;} public String getFlight_date () {return flight_date;} public void setFlight_date (String flight_date) {this.flight_date = flight_date;}
AirInfoManager.java
Import java.util.*;public class AirInfoManager {/ / method for listing all flights public void all_flight (ArrayList flight) {System.out.println ("number\ t flight number\ t destination\ t\ t departure date"); for (AirInfo e:flight) System.out.println (e.getId () + "\ t" + e.getFlight_number () + "\ t" + e.getDestination () + "+ e.getFlight_date () } / / query method by departure time public void inquiry_date (ArrayList flight) {System.out.print ("Please enter date:); Scanner in=new Scanner (System.in); String date=in.next (); for (AirInfo e:flight) {if (e.getFlight_date (). Equals (date)) {System.out.println (" No.\ t flight number\ t destination\ t departure date ") System.out.println (e.getId () + "\ t" + e.getFlight_number () + "\ t" + e.getDestination () + "+ e.getFlight_date ());} / / query method by destination public void inquiry_destination (ArrayList flight) {System.out.print (" Please enter destination: "); Scanner in=new Scanner (System.in); String destination=in.next () For (AirInfo e:flight) {if (e.getDestination (). Equals (destination)) {System.out.println ("number\ t flight number\ t destination\ t\ t departure date"); System.out.println (e.getId () + "\ t" + e.getFlight_number () + "\ t" + e.getDestination () + "+ e.getFlight_date () } / / method 1: delete the record by remove (index). Here, it is important to call the Iterator method to * avoid ConcurrentModificationException exceptions * public void delete_flight (ArrayList flight) {System.out.print ("Please enter the flight number to be deleted:"); Scanner in=new Scanner (System.in); int id=in.nextInt (); Iterator iterator = flight.iterator () While (iterator.hasNext ()) {AirInfo e = iterator.next (); if (e.getId () = = id) {iterator.remove (); System.out.println ("deleted successfully!") ; method 2: wrap the records to be deleted with an ArrayList () class, and * delete them with removeAll (Collection c) method * / public void delete_flight (ArrayList flight) {System.out.print ("Please enter the flight number to be deleted:"); Scanner in=new Scanner (System.in); List delList = new ArrayList (); int id=in.nextInt () For (AirInfo e:flight) {if (e.getId () = = (id)) delList.add (e);} flight.removeAll (delList); System.out.println ("deleted successfully!") Public void update_flight (ArrayList flight) {Scanner in=new Scanner (System.in); int id; String flight_number,destinaton,flight_date; System.out.print ("Please enter the flight code to be updated:"); id=in.nextInt (); System.out.print ("Please enter the new flight number:"); flight_number=in.next (); System.out.print ("Please enter the new destination:"); destinaton=in.next () System.out.print ("Please enter a new departure time:"); flight_date=in.next (); flight.add (new AirInfo (id,flight_number,destinaton,flight_date)); System.out.println ("updated successfully!") ;} / / method to exit the system public void exit () {System.out.println ("exit the system successfully!") ; System.exit (0);}}
TestAirInfo.java
Import java.util.ArrayList;import java.util.Scanner;// startup and operation system public class TestAirInfo {public static void main (String [] args) {AirInfoManager airInfoManager=new AirInfoManager (); / Arraylist represents flight information ArrayList flight=new ArrayList (); / / add records flight.add (new AirInfo (1,001 "," beijing "," 2016-1-1 ") to the array; flight.add (new AirInfo (2," 002 "," shanghai "," 2016-2-20 ")) Flight.add (new AirInfo (3, "003", "guangzhou", "2016-2-24"); Scanner in=new Scanner (System.in); while (true) {System.out.print ("Please select an action (1. List all flights, 2. Query by departure time, 3. Query by destination, 4. Delete flight, 5. Update flight, 6. Switch (in.nextInt ()) {case 1: airInfoManager.all_flight (flight); break; case 2: airInfoManager.inquiry_date (flight); break; case 3: airInfoManager.inquiry_destination (flight); break; case 4: airInfoManager.delete_flight (flight); break; case 5: airInfoManager.update_flight (flight); break; case 6: airInfoManager.exit (); default:System.out.println ("Sorry, the number you entered is invalid. Please enter the number between 1 and 6: ");} System.out.println ();} thank you for reading this article carefully. I hope the article" how to implement the flight information query and management system in java "shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.