Advertisement
Guest User

ollie > dan

a guest
May 31st, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.IO;
  8.  
  9. namespace Batham_Gate_Manor_Application_Unit_16_Assignment
  10. {
  11.     class Program
  12.     {
  13.         static string name = "";
  14.         static string address = "";
  15.         static string telephone_number = "";
  16.         static string check_in_date = "";
  17.         static string accom_type = "";
  18.         static string disabled = "";
  19.         static string smoking = "";
  20.         static int nights = 0;
  21.         static string adults = "";
  22.         static string children = "";
  23.         static int room_Price = 0;
  24.         static string username = "admin";
  25.         static string password = "password";
  26.         public static void dimensions()
  27.         {
  28.             Console.WindowHeight = 25;
  29.             Console.WindowWidth = 165;
  30.         }
  31.         static void Main(string[] args)
  32.         {
  33.             Console.Title = "Batham Gate Manor Hotel Application Unit 16 Assignment";
  34.             login();
  35.             //TextWriter dan = new StreamWriter(@"U:\Batham_Gate_Manor_Reservations.txt", true);
  36.             //TextReader nad = new StreamReader(@"U:\Batham_Gate_Manor_Reservations.txt", true);
  37.         }
  38.         static void login()
  39.         {
  40.             Console.WriteLine("Please enter Username: ");
  41.             username = Console.ReadLine();
  42.             Console.WriteLine("Please enter Password: ");
  43.             password = Console.ReadLine();
  44.             while (true)
  45.             {
  46.                 try
  47.                 {
  48.                     if (username.Equals("admin") || password.Equals("password"))
  49.                     {
  50.                         first();
  51.                     }
  52.                     else
  53.                     {
  54.                         Console.WriteLine("Please enter valid username and password.");
  55.                     }
  56.                 }
  57.                 catch
  58.                 {
  59.                     Console.WriteLine("Please enter something valid!");
  60.                 }
  61.             }
  62.         }
  63.         static void first()
  64.         {
  65.             Console.Clear();
  66.             string Word = "<Batham Gate Manor Hotel>\n";
  67.             int count = 0;
  68.             for (int i = 0; i < Word.Length; i++)
  69.             {
  70.                 if (count < 1)
  71.                 {
  72.                     Console.ForegroundColor = ConsoleColor.White;
  73.                     count++;
  74.                 }
  75.                 Console.Write(Word[i]);
  76.                 Thread.Sleep(50);
  77.             }
  78.             Console.WriteLine("Please choose one of the following options.");
  79.             Console.WriteLine("1) Create reservation");
  80.             Console.WriteLine("2) View existing reservations");
  81.             ConsoleKeyInfo selection = Console.ReadKey();
  82.             while (true)
  83.             {
  84.                 try
  85.                 {
  86.                     if (selection.Key == ConsoleKey.D1)
  87.                     {
  88.                         create_Res_Name();
  89.                     }
  90.                     else if (selection.Key == ConsoleKey.D2)
  91.                     {
  92.                         view_Res();
  93.                     }
  94.                 }
  95.                 catch
  96.                 {
  97.                     Console.WriteLine("Please enter something valid!");
  98.                 }
  99.             }
  100.         }
  101.         static void create_Res_Name()
  102.         {
  103.             Console.Clear();
  104.             Console.WriteLine("Enter customer full name");
  105.             name = Console.ReadLine();
  106.            
  107.             create_Res_Address();
  108.         }
  109.         static void create_Res_Address()
  110.         {
  111.             Console.Clear();
  112.             Console.WriteLine("Enter customer address");
  113.             address = Console.ReadLine();
  114.            
  115.             create_Res_Number();
  116.         }
  117.         static void create_Res_Number()
  118.         {
  119.             Console.Clear();
  120.             Console.WriteLine("Enter customer telephone number");
  121.             telephone_number = Console.ReadLine();
  122.            
  123.             create_Res_Date();
  124.         }
  125.         static void create_Res_Date()
  126.         {
  127.             Console.Clear();
  128.             Console.WriteLine("Enter customer check in date");
  129.             check_in_date = Console.ReadLine();
  130.            
  131.             create_Res_Disabled();
  132.         }
  133.        
  134.         static void create_Res_Disabled()
  135.         {
  136.             Console.Clear();
  137.             Console.WriteLine("Enter customer disability preferences");
  138.             Console.WriteLine("Required or none");
  139.             disabled = Console.ReadLine();
  140.            
  141.             create_Res_Smoker();
  142.         }
  143.         static void create_Res_Smoker()
  144.         {
  145.             Console.Clear();
  146.             Console.WriteLine("Enter customer smoking preferences");
  147.             Console.WriteLine("Smoker or none smoker");
  148.             smoking = Console.ReadLine();
  149.            
  150.             create_Res_Nights();
  151.         }
  152.         static void create_Res_Nights()
  153.         {
  154.             Console.Clear();
  155.             Console.WriteLine("Enter number of nights staying");
  156.             nights = int.Parse(Console.ReadLine());
  157.            
  158.             create_Res_Adults();
  159.         }
  160.         static void create_Res_Adults()
  161.         {
  162.             Console.Clear();
  163.             Console.WriteLine("Enter number of adults");
  164.             adults = Console.ReadLine();
  165.            
  166.             create_Res_Children();
  167.         }
  168.         static void create_Res_Children()
  169.         {
  170.             Console.Clear();
  171.             Console.WriteLine("Enter number of children");
  172.             children = Console.ReadLine();
  173.             create_Res_AccomType();
  174.             textWrite();
  175.         }
  176.  
  177.         static void create_Res_AccomType()
  178.         {
  179.             Console.Clear();
  180.             Console.WriteLine("Enter customer accomadation type");
  181.             Console.WriteLine("Please enter customer Accommodation Type.");
  182.             Console.WriteLine("1) Cosy Double");
  183.             Console.WriteLine("2) Double");
  184.             Console.WriteLine("3) Twin");
  185.             Console.WriteLine("4) Large Double");
  186.             Console.WriteLine("5) Large Twin");
  187.             Console.WriteLine("6) Family Room");
  188.             int choice = 0;
  189.             choice = int.Parse(Console.ReadLine());
  190.             if (choice == 1)
  191.             {
  192.                 accom_type = "cosy double";
  193.                 if (accom_type.Equals("cosy double") || adults.Equals("1"))
  194.                 {
  195.                     room_Price = 75 * nights;
  196.                 }
  197.                 else if (accom_type.Equals("cosy double") || adults.Equals("2"))
  198.                 {
  199.                     room_Price = 2 * 75 * nights;
  200.                 }
  201.             }
  202.             else if (choice == 2)
  203.             {
  204.                 accom_type = "double";
  205.                 if (accom_type.Equals("double") || adults.Equals("1"))
  206.                 {
  207.                     room_Price = 110 * nights;
  208.                 }
  209.                 else if (accom_type.Equals("double") || adults.Equals("2"))
  210.                 {
  211.                     room_Price = 2 * 110 * nights;
  212.                 }
  213.             }
  214.             else if (choice == 3)
  215.             {
  216.                 accom_type = "twin";
  217.                 if (accom_type.Equals("twin") || adults.Equals("1"))
  218.                 {
  219.                     room_Price = 110 * nights;
  220.                 }
  221.                 else if (accom_type.Equals("twin") || adults.Equals("2"))
  222.                 {
  223.                     room_Price = 2 * 110 * nights;
  224.                 }
  225.             }
  226.             else if (choice == 4)
  227.             {
  228.                 accom_type = "large double";
  229.                 if (accom_type.Equals("large double") || adults.Equals("1"))
  230.                 {
  231.                     room_Price = 155 * nights;
  232.                 }
  233.                 else if (accom_type.Equals("large double") || adults.Equals("2"))
  234.                 {
  235.                     room_Price = 2 * 155 * nights;
  236.                 }
  237.             }
  238.             else if (choice == 5)
  239.             {
  240.                 accom_type = "large twin";
  241.                 if (accom_type.Equals("large twin") || adults.Equals("1"))
  242.                 {
  243.                     room_Price = 155 * nights;
  244.                 }
  245.                 else if (accom_type.Equals("large twin") || adults.Equals("2"))
  246.                 {
  247.                     room_Price = 2 * 155 * nights;
  248.                 }
  249.                 else if (accom_type.Equals("large twin") || adults.Equals("1") || children.Equals("1"))
  250.                 {
  251.                     room_Price = 2 * 155 * nights;
  252.                 }
  253.                 else if (accom_type.Equals("large twin") || adults.Equals("2") || children.Equals("1"))
  254.                 {
  255.                     room_Price = 3 * 155 * nights;
  256.                 }
  257.             }
  258.             else if (choice == 6)
  259.             {
  260.                 accom_type = "family room";
  261.                 if (accom_type.Equals("family foom") || adults.Equals("1"))
  262.                 {
  263.                     room_Price = 225 * nights;
  264.                 }
  265.                 else if (accom_type.Equals("family room") || adults.Equals("2"))
  266.                 {
  267.                     room_Price = 2 * 225 * nights;
  268.                 }
  269.                 else if (accom_type.Equals("family room") || adults.Equals("1") || children.Equals("1"))
  270.                 {
  271.                     room_Price = 2 * 225 * nights;
  272.                 }
  273.                 else if (accom_type.Equals("family room") || adults.Equals("2") || children.Equals("1"))
  274.                 {
  275.                     room_Price = 3 * 225 * nights;
  276.                 }
  277.             }      
  278.             create_Res_Second();
  279.             textWrite();
  280.         }
  281.  
  282.         static void textWrite()
  283.         {
  284.             TextWriter dan = new StreamWriter("Batham_Gate_Manor_Reservations.txt");
  285.  
  286.             dan.WriteLine(name);
  287.             dan.WriteLine(address);
  288.             dan.WriteLine(telephone_number);
  289.             dan.WriteLine(check_in_date);
  290.             dan.WriteLine(accom_type);
  291.             dan.WriteLine(disabled);
  292.             dan.WriteLine(smoking);
  293.             dan.WriteLine(nights);
  294.             dan.WriteLine(adults);
  295.             dan.WriteLine(children);
  296.             dan.WriteLine(room_Price);
  297.             dan.Close();
  298.  
  299.         }
  300.  
  301.         static void create_Res_Second()
  302.         {
  303.             Console.WriteLine("Would you like to make another reservation?");
  304.             string choice = Console.ReadLine();
  305.             choice.ToUpper();
  306.             if (choice.Equals("yes"))
  307.             {
  308.                 create_Res_Name();
  309.             }
  310.             else if (choice.Equals("no"))
  311.             {
  312.                 first();
  313.             }
  314.         }
  315.         static void view_Res()
  316.         {
  317.             Console.Clear();
  318.             string line;
  319.             TextReader nad = new StreamReader("Batham_Gate_Manor_Reservations.txt");
  320.             while ((line = nad.ReadLine()) != null)
  321.             {
  322.                 Console.WriteLine(line);
  323.                 //nad.Close();
  324.                 //Console.ReadLine();
  325.             }
  326.         }
  327.     }
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement