Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp31
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime now = DateTime.Now;
- // Passenger first
- Passenger p1 = new Passenger("Fouz","milkyway","Andromeda","1","first");
- // Plane
- Plane balerion = new Plane();
- // Flight
- Flight f1 = new Flight(balerion, p1);
- Airport airport = new Airport(f1);
- Console.WriteLine(airport);
- Console.ReadKey();
- }
- }
- class Passenger
- {
- string name;
- string origin;
- string destination ;
- string passengers;
- string pclass;
- public Passenger(string n, string ori, string dest, string pass, string pc)
- {
- name = n; origin = ori; destination = dest; passengers = pass; Pclass = pc;
- }
- public string Pclass
- {
- get { return pclass; }
- // shorthand if-else
- set
- {
- if (value == "economy" || value == "bussines" || value == "first")
- {
- pclass = value;
- }
- // default value is economy.
- else
- {
- pclass = "economy";
- }
- }
- }
- public string Book()
- {
- string info = "BOOK INFORMATION: \n"+"NAME: "+name+"\nFROM: "+origin+" TO: "+destination+"\nCLASS: "+pclass;
- return info;
- }
- }
- //
- class Plane
- {
- string type;
- string seats;
- public Plane(string Type = "Balerion" , string Seats = "150")
- {
- type = Type; seats = Seats;
- }
- //methods
- public void TakeOff()
- {
- Console.WriteLine("*Taking off*");
- }
- public void Land()
- {
- Console.WriteLine("*Landing*");
- }
- public string Info()
- {
- return this.type + ", seats: " + this.seats;
- }
- }
- //
- class Flight
- {
- string flightN;
- string gatee;
- Passenger P11;
- Plane P1;
- public Flight(Plane p1, Passenger p11, string num = "11", string gate = "7")
- {
- P1 = p1;
- P11 = p11;
- flightN = num;
- gatee = gate;
- }
- // property
- public string Info()
- {
- return P11.Book()+"\nON PLANE: "+P1.Info()
- +"\nFlight Info:\n"+"Flight Number: "+this.flightN+", Gate: "+this.gatee+ "\n************\n";
- }
- }
- class Airport
- {
- string name;
- string city;
- Flight F1;
- public Airport(Flight f1,string n = "bonefire", string c = "Raccoon")
- {
- F1 = f1;
- name = n;
- city = c;
- }
- public override string ToString()
- {
- return string.Format("Airpor Info: \nAirport Name: "+this.name+", City: "+this.city+ "\n**********\n"+F1.Info());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement