Advertisement
Guest User

TicketSystem

a guest
Oct 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class MainClass {
  5.   public static void Main (string[] args) {
  6.   Queue<Reservation> reserve = new Queue<Reservation>();
  7.  
  8.   string name,sex; int age;
  9.  
  10.   int inp = 0, ticket =0;
  11.   int count =0;
  12.   int i =0;
  13.  
  14.   while(inp != 3)
  15.   {
  16.      Console.WriteLine("");
  17.     Console.WriteLine(" ----- Cenima Ticketing System -----");
  18.     Console.WriteLine("| 1. Reserve Ticket                 |");
  19.     Console.WriteLine("| 2. View Tickets                   |");
  20.     Console.WriteLine(" -----------------------------------");
  21.  
  22.     Console.WriteLine("");
  23.     Console.Write("Enter Number: ");
  24.     inp = int.Parse(Console.ReadLine());
  25.    
  26.    if(inp == 1)
  27.     {
  28.       Console.Write("Enter Number of Ticket: ");
  29.  
  30.       ticket = int.Parse(Console.ReadLine());
  31.  
  32.       Console.WriteLine("");
  33.  
  34.       for(i = 0; i < ticket; i++){
  35.  
  36.       count = i+1;
  37.  
  38.       Console.WriteLine("");
  39.       Console.WriteLine("Ticket {0}",count);
  40.       Console.Write("Enter Full Name: ");
  41.       name = Console.ReadLine();
  42.       Console.Write("Enter Age: ");
  43.       age = int.Parse(Console.ReadLine());
  44.       Console.Write("Enter Sex: M/F ");
  45.       sex = Console.ReadLine();
  46.  
  47.       Reservation res = new Reservation(count,name,age,sex);
  48.       reserve.Enqueue(res);
  49.       }
  50.  
  51.     }
  52.     else if(inp == 2)
  53.     {
  54.    
  55.  
  56.       Console.WriteLine("");
  57.       Console.WriteLine("Total Ticket: {0}",ticket);
  58.       foreach(Reservation r in reserve)
  59.       {
  60.           Console.WriteLine("Ticket: {0}",r.Ticket);
  61.           Console.WriteLine("Name : {0}",r.Name);
  62.           Console.WriteLine("Age : {0}",r.Age);
  63.           Console.WriteLine("Sex : {0}",r.Sex);
  64.           Console.WriteLine("");  
  65.       }
  66.     }
  67.   }
  68.   }
  69. }
  70. class Reservation
  71. {
  72.   private string name;
  73.   private int age;
  74.   private string sex;
  75.  private int ticket;
  76.  
  77.   public  Reservation(int aTicket, string aName, int aAge , string aSex)
  78.   {
  79.       name = aName;
  80.       age = aAge;
  81.       sex = aSex;
  82.      ticket = aTicket;
  83.   }
  84.  
  85.      
  86.     public int Ticket
  87.      {
  88.     get
  89.     {
  90.       return ticket;
  91.     }
  92.     set
  93.     {
  94.       ticket = value;
  95.     }
  96.   }
  97.  
  98.  
  99.   public string Name{
  100.     get
  101.     {
  102.       return name;
  103.     }
  104.     set
  105.     {
  106.       name = value;
  107.     }
  108.   }
  109.      public int Age{
  110.     get
  111.     {
  112.       return age;
  113.     }
  114.     set
  115.     {
  116.       age = value;
  117.     }
  118.      }
  119.      public string Sex
  120.      {
  121.     get
  122.     {
  123.       return sex;
  124.     }
  125.     set
  126.     {
  127.       sex = value;
  128.     }
  129.      }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement