uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

UseCase1_Main.java (1137B)


      1 import java.io.FileNotFoundException;
      2 import java.io.IOException;
      3 import java.util.Scanner;
      4 
      5 public class UseCase1_Main {
      6     public static void main(String[] args) throws IOException {
      7         Booker booker = new Booker();
      8         Scanner sc = new Scanner(System.in);
      9 
     10         System.out.println("Hello client, please enter your info :");
     11         ClientInfo c = booker.GetClientInfo();
     12 
     13         String []IDs = booker.SearchFlight();
     14 		while (IDs == null) {
     15 			System.out.println("Flight not found");
     16 			System.out.println("Do you wish to search for another flight? (Y/N)");
     17 			String ans = sc.nextLine();
     18 			if (!(ans.equals("Y") || ans.equals("y"))) { System.out.println("Goodbye!"); return; }
     19 			IDs = booker.SearchFlight();
     20 		}
     21 
     22 		Ticket t = booker.Database.BookSeat(c, Integer.parseInt(IDs[0]), IDs[1]);
     23 		booker.PrintTicket(t);
     24 
     25 		System.out.println("Ticket booked!");
     26 		System.out.println("Have a nice day!");
     27 
     28 		try
     29 		{
     30 			booker.Database.SaveDB("DataBase.db");
     31 			System.out.println("Ticket data saved.");
     32 		}
     33 		catch (IOException e)
     34 		{
     35 			System.out.println("Ticket data save failed (Insufficient permissions?)");
     36 		}
     37 
     38     }
     39 }