public static void SelectRoute(ConsoleScreen _screen, ConsoleKeyPad _keypad, int menuoption) { while (true) { _screen.WriteLine( @"Let's add a route, so enter a number that corresponds to one of the following routes:" + "\n" + @"1. Ferry goes from Maui to Lanai or vice versa for $30.00 (Adult) $20.00 (Child)" + "\n" + @"2. Ferry goes from Maui to Molokai or vice versa for $40.00 (Adult) $20.00 (Child)" + "\n" + @"3. Flight goes from Oahu to Maui or vice versa for $80.00" + "\n" + @"4. Flight goes from Oahu to Kona or vice versa for $100.00" + "\n" + @"5. Flight goes from Oahu to Kauai or vice versa for $50.00" ); try { menuoption = (int)_keypad.ReadLine(); break; } catch (Exception e) { _screen.WriteLine(e.Message); Console.WriteLine(); } } SelMode.SelectMode(_screen, _keypad, menuoption); }
static void Main(string[] args) { Console.WriteLine(" Welcome to Hawaiin inter-islands Travel !! " + "\n"); ConsoleScreen _screen = new ConsoleScreen(); ConsoleKeyPad _keypad = new ConsoleKeyPad(); int menuoption = 0; //first time get route route SelRoute.SelectRoute(_screen, _keypad, menuoption); nxtStep(_screen, _keypad, menuoption); }
public static void nxtStep(ConsoleScreen _screen, ConsoleKeyPad _keypad, int menuoption) { _screen.WriteLine("Enter 1 if you want pay;otherwise other input to add more routes"); int inp = (int)_keypad.ReadLine(); if (inp == 1) { //route flow to payment section CheckoutBill.Checkout(_screen, _keypad); } else { //get and add another route in array SelRoute.SelectRoute(_screen, _keypad, 0); nxtStep(_screen, _keypad, 0); } }
public static void Summary(ConsoleScreen _screen, ConsoleKeyPad _keypad, int menuoption, Route route) { if (menuoption == 1 || menuoption == 2) { routeArray.Add(((Ferry)route).ToString(route.priceAd)); } else { routeArray.Add(((Flight)route).ToString(route.priceAd)); } totalpayableamount += route._numOfPass * route.priceAd; Console.WriteLine(); foreach (String strr in routeArray) { _screen.WriteLine(strr); } _screen.WriteLine($"The total cost of this transaction is ${ totalpayableamount } "); Console.WriteLine(); }
public static void Checkout(ConsoleScreen _screen, ConsoleKeyPad _keypad) { bool isnotValid = false; do { _screen.WriteLine("Enter following payment options :"); _screen.WriteLine("1 : Check"); _screen.WriteLine("2: Credit card"); int opt = (int)_keypad.ReadLine(); if (opt == 1) { Check check = new Check(); _screen.WriteLine("Enter Bank Number (100000): "); int b_num = (int)_keypad.ReadLine(); _screen.WriteLine("Enter Routing Number (100000111) : "); int r_num = (int)_keypad.ReadLine(); try { check.BankNumber = b_num; check.RouteNumber = r_num; isnotValid = false; } catch (Exception e) { _screen.WriteLine(e.Message); Console.WriteLine(); isnotValid = true; } if (!isnotValid) { try { check.Deduct(Summarize.totalpayableamount); } catch (Exception e) { _screen.WriteLine(e.Message); Console.WriteLine(); } } } else { Card card = new Card(); try { _screen.WriteLine("Enter Card Number (1000100010001000) : "); long c_num = _keypad.ReadLine(); _screen.WriteLine("Enter Expiry Date ( 1130) : "); int e_num = (int)_keypad.ReadLine(); _screen.WriteLine("Enter CvV number : "); card.Cvv = (int)_keypad.ReadLine(); card.CreditCardNum = c_num; card.ExpDate = e_num; isnotValid = false; } catch (Exception e) { _screen.WriteLine(e.Message); Console.WriteLine(); isnotValid = true; } if (!isnotValid) { try { card.Deduct(Summarize.totalpayableamount); } catch (Exception e) { _screen.WriteLine(e.Message); Console.WriteLine(); } } } } while (isnotValid); _screen.WriteLine($"Payment successful"); _screen.WriteLine($"Your available balance is {Payment._amount}"); Console.WriteLine(); }
public static void SelectMode(ConsoleScreen _screen, ConsoleKeyPad _keypad, int menuoption) { if (menuoption == 1) { _screen.WriteLine("Enter 1 if you want to go from Maui to Lanai; otherwise, you want to go from Lanai to Maui"); int inp = (int)_keypad.ReadLine(); Ferry1 f1 = new Ferry1(); if (inp == 1) { f1._fromIsland = "Maui"; f1._toIsland = "Lanai"; } else { f1._fromIsland = "Lanai"; f1._toIsland = "Maui"; } _screen.WriteLine("Enter 1 if you want to add number of child passengers; otherwise for adult persons"); inp = (int)_keypad.ReadLine(); if (inp == 1) { f1.priceAd = 20M; } else { f1.priceAd = 30M; } _screen.WriteLine("Enter number of passengers"); f1._numOfPass = (int)_keypad.ReadLine(); Summarize.Summary(_screen, _keypad, menuoption, f1); } else if (menuoption == 2) { _screen.WriteLine("Enter 1 if you want to go from Maui to Molokai; otherwise, you want to go from Molokai to Maui"); int inp = (int)_keypad.ReadLine(); Ferry1 f2 = new Ferry1(); if (inp == 1) { f2._fromIsland = "Maui"; f2._toIsland = "Molokai"; } else { f2._fromIsland = "Molokai"; f2._toIsland = "Maui"; } _screen.WriteLine("Enter 1 if you want to add number of child passengers; otherwise for adult persons"); inp = (int)_keypad.ReadLine(); if (inp == 1) { f2.priceAd = 40M; } else { f2.priceAd = 20M; } _screen.WriteLine("Enter number of passengers"); f2._numOfPass = (int)_keypad.ReadLine(); Summarize.Summary(_screen, _keypad, menuoption, f2); } else if (menuoption == 3) { _screen.WriteLine("Enter 1 if you want to go from Oahu to Maui; otherwise, you want to go from Maui to Oahu"); int inp = (int)_keypad.ReadLine(); Flight1 f3 = new Flight1(); f3.priceAd = 80M; if (inp == 1) { f3._fromIsland = "Oahu"; f3._toIsland = "Maui"; } else { f3._fromIsland = "Maui"; f3._toIsland = "Oahu"; } _screen.WriteLine("Enter number of passengers"); f3._numOfPass = (int)_keypad.ReadLine(); Summarize.Summary(_screen, _keypad, menuoption, f3); } else if (menuoption == 4) { _screen.WriteLine("Enter 1 if you want to go from Oahu to Kona ; otherwise, you want to go from Kona to Oahu"); int inp = (int)_keypad.ReadLine(); Flight2 f4 = new Flight2(); f4.priceAd = 100M; if (inp == 1) { f4._fromIsland = "Oahu"; f4._toIsland = "Kona"; } else { f4._fromIsland = "Kona"; f4._toIsland = "Oahu"; } _screen.WriteLine("Enter number of passengers"); f4._numOfPass = (int)_keypad.ReadLine(); Summarize.Summary(_screen, _keypad, menuoption, f4); } else if (menuoption == 5) { _screen.WriteLine("Enter 1 if you want to go from Oahu to Kauai; otherwise, you want to go from Kauai to Oahu"); int inp = (int)_keypad.ReadLine(); Flight3 f5 = new Flight3(); f5.priceAd = 50M; if (inp == 1) { f5._fromIsland = "Oahu"; f5._toIsland = "Kauai"; } else { f5._fromIsland = "Oahu"; f5._toIsland = "Honolulu"; } _screen.WriteLine("Enter number of passengers"); f5._numOfPass = (int)_keypad.ReadLine(); Summarize.Summary(_screen, _keypad, menuoption, f5); } }