Advertisement
Guest User

Airport

a guest
Oct 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.28 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.  
  7. namespace ConsoleApp31
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             DateTime now = DateTime.Now;
  14.  
  15.  
  16.             // Passenger first
  17.             Passenger p1 = new Passenger("Fouz","milkyway","Andromeda","1","first");
  18.  
  19.             // Plane
  20.             Plane balerion = new Plane();
  21.  
  22.             // Flight
  23.             Flight f1 = new Flight(balerion, p1);
  24.  
  25.             Airport airport = new Airport(f1);
  26.             Console.WriteLine(airport);
  27.  
  28.             Console.ReadKey();
  29.         }
  30.     }
  31.     class Passenger
  32.     {
  33.         string name;
  34.         string origin;
  35.         string destination ;
  36.         string passengers;
  37.         string pclass;
  38.  
  39.         public Passenger(string n, string ori, string dest, string pass, string pc)
  40.         {
  41.             name = n; origin = ori; destination = dest; passengers = pass; Pclass = pc;
  42.                
  43.         }
  44.         public string Pclass
  45.         {
  46.             get { return pclass; }
  47.             // shorthand if-else
  48.             set
  49.             {
  50.                 if (value == "economy" || value == "bussines" || value == "first")
  51.                 {
  52.                     pclass = value;
  53.                 }
  54.                 // default value is economy.
  55.                 else
  56.                 {
  57.                     pclass = "economy";
  58.                 }
  59.             }
  60.         }
  61.         public string Book()
  62.         {
  63.             string info = "BOOK INFORMATION: \n"+"NAME: "+name+"\nFROM: "+origin+" TO: "+destination+"\nCLASS: "+pclass;
  64.             return info;
  65.         }
  66.     }
  67.  
  68.     //
  69.     class Plane
  70.     {
  71.         string type;
  72.         string seats;
  73.         public Plane(string Type = "Balerion" , string Seats = "150")
  74.         {
  75.             type = Type; seats = Seats;
  76.         }
  77.  
  78.         //methods
  79.  
  80.         public void TakeOff()
  81.         {
  82.             Console.WriteLine("*Taking off*");
  83.         }
  84.         public void Land()
  85.         {
  86.             Console.WriteLine("*Landing*");
  87.         }
  88.  
  89.         public string Info()
  90.         {
  91.             return this.type + ", seats: " + this.seats;
  92.         }
  93.  
  94.     }
  95.     //
  96.  
  97.     class Flight
  98.     {
  99.         string flightN;
  100.         string gatee;
  101.  
  102.         Passenger P11;
  103.         Plane P1;
  104.         public Flight(Plane p1, Passenger p11, string num = "11", string gate = "7")
  105.         {
  106.             P1 = p1;
  107.             P11 = p11;
  108.  
  109.             flightN = num;
  110.             gatee = gate;
  111.  
  112.         }
  113.  
  114.         // property
  115.         public string Info()
  116.         {
  117.             return P11.Book()+"\nON PLANE: "+P1.Info()
  118.                 +"\nFlight Info:\n"+"Flight Number: "+this.flightN+", Gate: "+this.gatee+ "\n************\n";
  119.         }
  120.     }
  121.  
  122.     class Airport
  123.     {
  124.         string name;
  125.         string city;
  126.         Flight F1;
  127.         public Airport(Flight f1,string n = "bonefire", string c = "Raccoon")
  128.         {
  129.             F1 = f1;
  130.             name = n;
  131.             city = c;
  132.         }
  133.         public override string ToString()
  134.         {
  135.             return string.Format("Airpor Info: \nAirport Name: "+this.name+", City: "+this.city+ "\n**********\n"+F1.Info());
  136.         }
  137.  
  138.     }
  139.    
  140.  
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement