Advertisement
Guest User

yolo

a guest
May 31st, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.17 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.                 if (selection.Key == ConsoleKey.D1)
  85.                 {
  86.                     create_Res_Name();
  87.                 }
  88.                 else if (selection.Key == ConsoleKey.D2)
  89.                 {
  90.                     string line;
  91.                    
  92.                     TextReader nad = new StreamReader("Batham_Gate_Manor_Reservations.txt", true);
  93.                     while ((line = nad.ReadLine()) != null)
  94.                     {
  95.                         Console.WriteLine(line);
  96.                         //nad.Close();
  97.                         //Console.ReadLine();
  98.                     }
  99.                 }
  100.             }
  101.         }
  102.         static void create_Res_Name()
  103.         {
  104.             Console.Clear();
  105.             Console.WriteLine("Enter customer full name");
  106.             name = Console.ReadLine();
  107.            
  108.             create_Res_Address();
  109.         }
  110.         static void create_Res_Address()
  111.         {
  112.             Console.Clear();
  113.             Console.WriteLine("Enter customer address");
  114.             address = Console.ReadLine();
  115.            
  116.             create_Res_Number();
  117.         }
  118.         static void create_Res_Number()
  119.         {
  120.             Console.Clear();
  121.             Console.WriteLine("Enter customer telephone number");
  122.             telephone_number = Console.ReadLine();
  123.            
  124.             create_Res_Date();
  125.         }
  126.         static void create_Res_Date()
  127.         {
  128.             Console.Clear();
  129.             Console.WriteLine("Enter customer check in date");
  130.             check_in_date = Console.ReadLine();
  131.            
  132.             create_Res_Disabled();
  133.         }
  134.        
  135.         static void create_Res_Disabled()
  136.         {
  137.             Console.Clear();
  138.             Console.WriteLine("Enter customer disability preferences");
  139.             Console.WriteLine("Required or none");
  140.             disabled = Console.ReadLine();
  141.            
  142.             create_Res_Smoker();
  143.         }
  144.         static void create_Res_Smoker()
  145.         {
  146.             Console.Clear();
  147.             Console.WriteLine("Enter customer smoking preferences");
  148.             Console.WriteLine("Smoker or none smoker");
  149.             smoking = Console.ReadLine();
  150.            
  151.             create_Res_Nights();
  152.         }
  153.         static void create_Res_Nights()
  154.         {
  155.             Console.Clear();
  156.             Console.WriteLine("Enter number of nights staying");
  157.             nights = int.Parse(Console.ReadLine());
  158.            
  159.             create_Res_Adults();
  160.         }
  161.         static void create_Res_Adults()
  162.         {
  163.             Console.Clear();
  164.             Console.WriteLine("Enter number of adults");
  165.             adults = Console.ReadLine();
  166.            
  167.             create_Res_Children();
  168.         }
  169.         static void create_Res_Children()
  170.         {
  171.             Console.Clear();
  172.             Console.WriteLine("Enter number of children");
  173.             children = Console.ReadLine();
  174.             create_Res_AccomType();
  175.             textWrite();
  176.         }
  177.  
  178.         static void create_Res_AccomType()
  179.         {
  180.             Console.Clear();
  181.             Console.WriteLine("Enter customer accomadation type");
  182.             Console.WriteLine("Please enter customer Accommodation Type.");
  183.             Console.WriteLine("1) Cosy Double");
  184.             Console.WriteLine("2) Double");
  185.             Console.WriteLine("3) Twin");
  186.             Console.WriteLine("4) Large Double");
  187.             Console.WriteLine("5) Large Twin");
  188.             Console.WriteLine("6) Family Room");
  189.             int choice = 0;
  190.             choice = int.Parse(Console.ReadLine());
  191.             if (choice == 1)
  192.             {
  193.                 accom_type = "cosy double";
  194.                 if (accom_type.Equals("cosy double") || adults.Equals("1"))
  195.                 {
  196.                     room_Price = 75 * nights;
  197.                 }
  198.                 else if (accom_type.Equals("cosy double") || adults.Equals("2"))
  199.                 {
  200.                     room_Price = 2 * 75 * nights;
  201.                 }
  202.             }
  203.             else if (choice == 2)
  204.             {
  205.                 accom_type = "double";
  206.                 if (accom_type.Equals("double") || adults.Equals("1"))
  207.                 {
  208.                     room_Price = 110 * nights;
  209.                 }
  210.                 else if (accom_type.Equals("double") || adults.Equals("2"))
  211.                 {
  212.                     room_Price = 2 * 110 * nights;
  213.                 }
  214.             }
  215.             else if (choice == 3)
  216.             {
  217.                 accom_type = "twin";
  218.                 if (accom_type.Equals("twin") || adults.Equals("1"))
  219.                 {
  220.                     room_Price = 110 * nights;
  221.                 }
  222.                 else if (accom_type.Equals("twin") || adults.Equals("2"))
  223.                 {
  224.                     room_Price = 2 * 110 * nights;
  225.                 }
  226.             }
  227.             else if (choice == 4)
  228.             {
  229.                 accom_type = "large double";
  230.                 if (accom_type.Equals("large double") || adults.Equals("1"))
  231.                 {
  232.                     room_Price = 155 * nights;
  233.                 }
  234.                 else if (accom_type.Equals("large double") || adults.Equals("2"))
  235.                 {
  236.                     room_Price = 2 * 155 * nights;
  237.                 }
  238.             }
  239.             else if (choice == 5)
  240.             {
  241.                 accom_type = "large twin";
  242.                 if (accom_type.Equals("large twin") || adults.Equals("1"))
  243.                 {
  244.                     room_Price = 155 * nights;
  245.                 }
  246.                 else if (accom_type.Equals("large twin") || adults.Equals("2"))
  247.                 {
  248.                     room_Price = 2 * 155 * nights;
  249.                 }
  250.                 else if (accom_type.Equals("large twin") || adults.Equals("1") || children.Equals("1"))
  251.                 {
  252.                     room_Price = 2 * 155 * nights;
  253.                 }
  254.                 else if (accom_type.Equals("large twin") || adults.Equals("2") || children.Equals("1"))
  255.                 {
  256.                     room_Price = 3 * 155 * nights;
  257.                 }
  258.             }
  259.             else if (choice == 6)
  260.             {
  261.                 accom_type = "family room";
  262.                 if (accom_type.Equals("family foom") || adults.Equals("1"))
  263.                 {
  264.                     room_Price = 225 * nights;
  265.                 }
  266.                 else if (accom_type.Equals("family room") || adults.Equals("2"))
  267.                 {
  268.                     room_Price = 2 * 225 * nights;
  269.                 }
  270.                 else if (accom_type.Equals("family room") || adults.Equals("1") || children.Equals("1"))
  271.                 {
  272.                     room_Price = 2 * 225 * nights;
  273.                 }
  274.                 else if (accom_type.Equals("family room") || adults.Equals("2") || children.Equals("1"))
  275.                 {
  276.                     room_Price = 3 * 225 * nights;
  277.                 }
  278.             }      
  279.             create_Res_Second();
  280.             textWrite();
  281.         }
  282.  
  283.         static void textWrite()
  284.         {
  285.             TextWriter dan = new StreamWriter("Batham_Gate_Manor_Reservations.txt");
  286.  
  287.             dan.WriteLine(name);
  288.             dan.WriteLine(address);
  289.             dan.WriteLine(telephone_number);
  290.             dan.WriteLine(check_in_date);
  291.             dan.WriteLine(accom_type);
  292.             dan.WriteLine(disabled);
  293.             dan.WriteLine(smoking);
  294.             dan.WriteLine(nights);
  295.             dan.WriteLine(adults);
  296.             dan.WriteLine(children);
  297.             dan.WriteLine(room_Price);
  298.             dan.Close();
  299.  
  300.         }
  301.  
  302.         static void create_Res_Second()
  303.         {
  304.             Console.WriteLine("Would you like to make another reservation?");
  305.             string choice = Console.ReadLine();
  306.             choice.ToUpper();
  307.             if (choice.Equals("yes"))
  308.             {
  309.                 create_Res_Name();
  310.             }
  311.             else if (choice.Equals("no"))
  312.             {
  313.                 first();
  314.             }
  315.         }
  316.         //static void view_Res()
  317.         //{
  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