/// <summary> /// Saturday West AM Report /// </summary> public void satWestAM() { string[,] carriageA = SatWestAM.returnCarriageA(); string[,] carriageB = SatWestAM.returnCarriageB(); string[,] carriageC = SatWestAM.returnCarriageC(); string[,] carriageD = SatWestAM.returnCarriageD(); StreamWriter file = new System.IO.StreamWriter(@".\\SatWestAM.txt", true); for (int i = 0; i < carriageA.Length / 2; i++) { Console.WriteLine("Seat Number: " + carriageA[i, 0]); Console.WriteLine("Passenger Name: " + carriageA[i, 1]); file.WriteLine("Seat Number: " + carriageA[i, 0]); file.WriteLine("Passenger Name: " + carriageA[i, 1]); } for (int i = 0; i < carriageB.Length / 2; i++) { Console.WriteLine("Seat Number: " + carriageB[i, 0]); Console.WriteLine("Passenger Name: " + carriageB[i, 1]); file.WriteLine("Seat Number: " + carriageB[i, 0]); file.WriteLine("Passenger Name: " + carriageB[i, 1]); } for (int i = 0; i < carriageC.Length / 2; i++) { Console.WriteLine("Seat Number: " + carriageC[i, 0]); Console.WriteLine("Passenger Name: " + carriageC[i, 1]); file.WriteLine("Seat Number: " + carriageC[i, 0]); file.WriteLine("Passenger Name: " + carriageC[i, 1]); } for (int i = 0; i < carriageD.Length / 2; i++) { Console.WriteLine("Seat Number: " + carriageD[i, 0]); Console.WriteLine("Passenger Name: " + carriageD[i, 1]); file.WriteLine("Seat Number: " + carriageD[i, 0]); file.WriteLine("Passenger Name: " + carriageD[i, 1]); } Console.WriteLine("Bags booked:" + SatWestAM.baggageSpaces); file.WriteLine("Bags booked:" + SatWestAM.baggageSpaces); Console.WriteLine("Report files written to the Project File. File Location (OldTimeRail - OldTimeRail - bin - Debug)"); }
/// <summary> /// Booking Class - Inputs Passenger information and calculates time and day of travel from user input. /// </summary> public Booking() { ///////////////////////////////////////////////////////////////// ////// ////// ////// User enters details ////// ////// Store them in variables ////// ////// ////// ///////////////////////////////////////////////////////////////// //Customer Information Variables string customerName; int carriageClass = 0; int carriageType = 0; int startStop = 0; int endStop = 0; int day = 0; int time = 0; string inputPartySize; int partySize; string inputSuitcaseNo; int suitcaseNo = 0; //Switch Statment variables string userSelection = ""; int userInput = 0; //Input Customer Name Console.Clear(); Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please enter the passenger name: "); customerName = Console.ReadLine(); //Input Carriage Class Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please choose Carriage Class "); Console.WriteLine("1) First Class"); Console.WriteLine("2) Third Class"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); switch (userSelection) { case "1": carriageClass = 1; break; case "2": carriageClass = 3; break; default: Console.WriteLine("Please enter a correct number"); break; } //Input Carriage Type Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please choose Carriage Type "); Console.WriteLine("1) Compartment Carriage"); Console.WriteLine("2) Standard Carriage"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); switch (userSelection) { case "1": carriageType = 1; break; case "2": carriageType = 2; break; default: Console.WriteLine("Please enter a correct number"); break; } //Input Start Stop Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please select the start station "); Console.WriteLine("1) Beggin Terminal"); Console.WriteLine("2) Sudden Halt"); Console.WriteLine("3) Muthly Pass"); Console.WriteLine("4) Conn Junction"); Console.WriteLine("5) Endline Station"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); switch (userSelection) { case "1": startStop = 1; break; case "2": startStop = 2; break; case "3": startStop = 3; break; case "4": startStop = 4; break; case "5": startStop = 5; break; default: Console.WriteLine("Please enter a correct Station"); break; } //Input End Stop Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please select the destination station"); Console.WriteLine("1) Beggin Terminal"); Console.WriteLine("2) Sudden Halt"); Console.WriteLine("3) Muthly Pass"); Console.WriteLine("4) Conn Junction"); Console.WriteLine("5) Endline Station"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); if (userInput == startStop) { Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please enter different stops for start and destination."); //Input End Stop Console.WriteLine(" Please select the Destination station "); Console.WriteLine("1) Beggin Terminal"); Console.WriteLine("2) Sudden Halt"); Console.WriteLine("3) Muthly Pass"); Console.WriteLine("4) Conn Junction"); Console.WriteLine("5) Endline Station"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); } else { switch (userSelection) { case "1": endStop = 1; break; case "2": endStop = 2; break; case "3": endStop = 3; break; case "4": endStop = 4; break; case "5": endStop = 5; break; default: Console.WriteLine("Please enter a correct Station"); break; } } //Day of Travel Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Which Day would you like to travel? "); Console.WriteLine("1) Saturday"); Console.WriteLine("2) Sunday"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); switch (userSelection) { case "1": day = 1; break; case "2": day = 2; break; default: Console.WriteLine("Please enter a correct number"); break; } //Time of Travel Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" What time would you like to travel?"); Console.WriteLine("1) AM"); Console.WriteLine("2) PM"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); switch (userSelection) { case "1": time = 1; break; case "2": time = 2; break; default: Console.WriteLine("Please enter a correct number"); break; } //Input Party Size Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" How many passengers will be travelling?"); inputPartySize = Console.ReadLine(); partySize = Int32.Parse(inputPartySize); //Baggage Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Would you like to add any bags?"); Console.WriteLine("1) Yes"); Console.WriteLine("2) No"); userSelection = Console.ReadLine(); userInput = Int32.Parse(userSelection); switch (userSelection) { case "1": Console.WriteLine("Please enter how many bags you would like to add"); inputSuitcaseNo = Console.ReadLine(); suitcaseNo = Int32.Parse(inputSuitcaseNo); break; case "2": suitcaseNo = 0; break; default: break; } ///////////////////////////////////////////////////////////////// ////// ////// ////// Create a new journey to calc direction ////// ////// If statements to calc carriage ////// ////// ////// ///////////////////////////////////////////////////////////////// Journey journey = new Journey(startStop, endStop); //Now have all of the customer information need to work out what train they want //Saturday AM East if (day == 1 && time == 1 && journey.calculateDirection() == "east") { if (carriageClass == 1) { SatEastAM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SatEastAM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SatEastAM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have entered incorrect details."); } } //Saturday AM West else if (day == 1 && time == 1 && journey.calculateDirection() == "west") { if (carriageClass == 1) { SatWestAM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SatWestAM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SatWestAM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have entered incorrect details."); } } //Saturday PM East else if (day == 1 && time == 2 && journey.calculateDirection() == "east") { if (carriageClass == 1) { SatEastPM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SatEastPM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SatEastPM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have entered incorrect details."); } } //Saturday PM West else if (day == 1 && time == 2 && journey.calculateDirection() == "west") { if (carriageClass == 1) { SatWestPM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SatWestPM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SatWestPM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have entered incorrect details."); } } //Sunday AM East else if (day == 2 && time == 1 && journey.calculateDirection() == "east") { if (carriageClass == 1) { SunEastAM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SunEastAM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SunEastAM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have selected incorrect details."); } } //Sunday AM West else if (day == 2 && time == 1 && journey.calculateDirection() == "west") { if (carriageClass == 1) { SunWestAM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SunWestAM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SunWestAM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have selected incorrect details."); } } //Sunday PM East else if (day == 2 && time == 2 && journey.calculateDirection() == "east") { if (carriageClass == 1) { SunEastPM.bookCarriageA(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SunEastPM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SunEastPM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have selected incorrect details."); } } //Sunday PM West else if (day == 2 && time == 2 && journey.calculateDirection() == "west") { if (carriageClass == 1) { SunWestPM.bookCarriageC(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 1) { SunWestPM.bookCarriageB(partySize, customerName, suitcaseNo); } else if (carriageClass == 3 && carriageType == 2) { SunWestPM.bookCarriageC(partySize, customerName, suitcaseNo); } else { Console.WriteLine("You have entered incorrect details. Please try again."); } } }
/// <summary> /// Old Time Rail Booking System. /// Created by SID: 1503126 /// Program class to intiate new carriages and run Main Menu. /// </summary> /// <param name="args"></param> static void Main(string[] args) { //Initialise Saturday East AM Train SatEastAM.initialiseA(); SatEastAM.initialiseB(); SatEastAM.initialiseC(); SatEastAM.initialiseD(); //Initialise Saturday East PM Train SatEastPM.initialiseA(); SatEastPM.initialiseB(); SatEastPM.initialiseC(); SatEastPM.initialiseD(); //Initialise Saturday West AM Train SatWestAM.initialiseA(); SatWestAM.initialiseB(); SatWestAM.initialiseC(); SatWestAM.initialiseD(); //Initalise Saturday West PM Train SatWestPM.initialiseA(); SatWestPM.initialiseB(); SatWestPM.initialiseC(); SatWestPM.initialiseD(); //Initalise Sunday East AM Train SunEastAM.initialiseA(); SunEastAM.initialiseB(); SunEastAM.initialiseC(); SunEastAM.initialiseD(); //Initalise Sunday East PM Train SunEastPM.initialiseA(); SunEastPM.initialiseB(); SunEastPM.initialiseC(); SunEastPM.initialiseD(); //Initalise Sunday West AM Train SunWestAM.initialiseA(); SunWestAM.initialiseB(); SunWestAM.initialiseC(); SunWestAM.initialiseD(); //Initalise Sunday West PM Train SunWestPM.initialiseA(); SunWestPM.initialiseB(); SunWestPM.initialiseC(); SunWestPM.initialiseD(); //Test Bookings Without UI /* SatEastAM.bookCarriageA(5, "Thorbinson", 8); * SatEastAM.bookCarriageB(4, "Lewis", 3); * SatEastAM.bookCarriageC(7, "Harris", 8); * SatEastAM.bookCarriageD(3, "Smith", 0); * * SatEastPM.bookCarriageA(4, "Styles", 2); * SatEastPM.bookCarriageB(6, "Mouse", 6); * SatEastPM.bookCarriageC(1, "Yankee", 0); * SatEastPM.bookCarriageD(2, "Litt", 1); * SatEastAM.bookCarriageA(8, "hi", 10); * SatEastAM.bookCarriageA(8, "hi", 10); * SatEastAM.bookCarriageA(8, "hi", 10); * SatEastAM.bookCarriageA(8, "hi", 9); */ //User Interface bool replay = true; while (replay == true) { string userInput; int userSelection; Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Welcome to the Old Time Rail Booking System "); Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine(" Please select an option from the list below. "); Console.WriteLine("_______________________________________________________________________"); Console.WriteLine(""); Console.WriteLine("1) New booking"); Console.WriteLine("2) Reports"); Console.WriteLine("3) View timetable"); Console.WriteLine("4) Help"); Console.WriteLine("9) Exit"); userInput = Console.ReadLine(); userSelection = int.Parse(userInput); switch (userSelection) { case 1: Console.WriteLine("New Booking"); Booking Booking = new Booking(); break; case 2: Report Report = new Report(); Report.NewReport(); break; case 3: Console.WriteLine("Timetable"); Timetable Timetable = new Timetable(); Timetable.timetable(); break; case 4: Help help = new Help(); help.HelpMe(); break; case 9: Console.WriteLine("Exit"); replay = false; break; } Console.ReadLine(); } }