//method used to check the state of the sales public static void CheckState(Flight flight) { Boeing toCheck = (Boeing)flight; string canbuyticket = toCheck.CanBuyTickets(); Console.WriteLine(canbuyticket); }
static void Main(string[] args) { Tower tower = new Tower(); Aircraft flight1 = new Airbus("AC159", tower); Aircraft flight2 = new Boeing("WS203", tower); Aircraft flight3 = new Fokker("AC602", tower); flight1.Altitude += 1000; }
static void Main(string[] args) { IAirTrafficController tower = new ConcreteTower(); Aircraft Boeing = new Boeing("Boeing777", tower); Aircraft AirBus = new AirBus("AirBus380", tower); Aircraft Foker = new Foker("Foker", tower); Boeing.Altitude = 34000; AirBus.Altitude = 34500; Foker.Altitude = 40000; }
public static void Main() { IAirTrafficControl tower = new Tower(); Airplane flightOne = new Airbus("AC159", tower); Airplane flightTwo = new Boeing("WS203", tower); flightOne.CurrentAltitude = 9000; flightTwo.CurrentAltitude = 7500; flightOne.CurrentAltitude -= 1000; }
static void Main(string[] args) { var pasPlane = new PassangerPlane(500, "Airplane"); var militarPlane = new MilitaryPlane(2000, true, "F15"); var boeingPlane = new Boeing(9, 450, "SARL 0ER5"); var plane = new TU134(15, 250, "AR 220"); pasPlane.Display(); var newPasPlane = pasPlane as Aviation; if (newPasPlane != null) { Console.WriteLine("Я преобразован в Aviation"); } else { Console.WriteLine("Ooops!"); } if (militarPlane is Aviation) { Console.WriteLine("Объект может быть преобразован в тип Aviation"); } else { Console.WriteLine("militarPlane ne может быть преобразован в тип Aviation"); } ((IName1)plane).GetName(); ((IName2)plane).GetName(); Print.IamPrinting(pasPlane); Print.IamPrinting(plane); //End of 5lab. //6 lab has been started Container <Aviation> contain = new Container <Aviation>(); contain.add(new PassangerPlane(480, "Airbus A370")); contain.add(new PassangerPlane(100, "YAK 40")); contain.add(new Boeing(15, 400, "Boeing 747")); contain.add(new TU134(20, 145, "TU_134")); contain.add(new MilitaryPlane(750, true, "F15")); contain.add(new MilitaryPlane(900, true, "Eurofighter")); Controller.GenerallPasCapacity(contain); Controller.SortingByDescending(contain); Console.ReadKey(); }
public override bool Equals(object obj) { if (obj == null) { return(false); } Boeing c = obj as Boeing; if (c as Boeing == null) { return(false); } return(this == (Boeing)obj); }
public static void Main() { // Build a collection of all vehicles that fly Cessna newCessna = new Cessna(); Boeing newBoeing = new Boeing(); List <IAir> airVehicles = new List <IAir>(); airVehicles.Add(newCessna); airVehicles.Add(newBoeing); // With a single `foreach`, have each vehicle Fly() foreach (var vehicle in airVehicles) { vehicle.Fly(); } // Build a collection of all vehicles that operate on roads Motorcycle newCycle = new Motorcycle(); BMW newBmw = new BMW(); List <IGround> groundVehicles = new List <IGround>(); groundVehicles.Add(newCycle); groundVehicles.Add(newBmw); // With a single `foreach`, have each road vehicle Drive() foreach (var vehicle in groundVehicles) { vehicle.Drive(); } // Build a collection of all vehicles that operate on water JetSki newJetski = new JetSki(); Yacht newYacht = new Yacht(); List <IWater> waterVehicles = new List <IWater>(); waterVehicles.Add(newJetski); waterVehicles.Add(newYacht); // With a single `foreach`, have each water vehicle Drive() foreach (var vehicle in waterVehicles) { vehicle.Drive(); } }
public static void Main() { var airbus = new Airbus(); var boeing = new Boeing(); var dinghy = new Dinghy(); var titanic = new Yacht(); var sequoia = new Sequoia(); var beetle = new Beetle(); // Build a collection of all vehicles that fly // With a single `foreach`, have each vehicle Fly() var flyings = new List <Aircraft> { airbus, boeing }; foreach (var flying in flyings) { flying.Flying(); } // Build a collection of all vehicles that operate on roads // With a single `foreach`, have each road vehicle Drive() var drivings = new List <Car> { sequoia, beetle }; foreach (var driving in drivings) { driving.Driving(); } // Build a collection of all vehicles that operate on water // With a single `foreach`, have each water vehicle Drive() var waterings = new List <Watercraft> { dinghy, titanic }; foreach (var watering in waterings) { watering.Driving(); } }
public static void Run() { Console.WriteLine("Second showcase is the AbstractFactoryGeneric design pattern."); Console.WriteLine("The Factory is the entry point for creating entities." + Environment.NewLine + "This is an interface/class declares and implements the generic methods for creating entities."); Console.WriteLine("Since it's generic, other classes can implement the original interface according to " + Environment.NewLine + "specific needs. These new factories are then called by providing the right type of generic."); Console.WriteLine("These sub-factories have generics which are meant to recoignise which entity to create. " + Environment.NewLine + "Creating the entities is then done by calling the Create method with desired generic type." + Environment.NewLine); // The Main Factory uses generic types to actually fire a Build method from desired factory. // The factory can only create the kind of product defined by generic type given. // Create instances of factrories for types of products Factory <Car> carFactory = new Factory <Car>(); Factory <Plane> planeFactory = new Factory <Plane>(); // Create products through factories meant for those kinds of products IProduct <Car> carProduct = carFactory.Create <Toyota>(); carProduct.Operate(); // Depending on the type of defined variable, different methods are available on object // Instantiating the product in a variable of interface type hides methods defined in class type Boeing planeProduct = planeFactory.Create <Boeing>(); planeProduct.Operate(); planeProduct.BoeingSpecificOperation(); IProduct <Car> carPartProduct = carFactory.Create <Engine <Car> >(); carPartProduct.Operate(); Frame <Car> carFrame = carFactory.Create <Frame <Car> >(); carFrame.FrameSpecificOperation(); carFrame.Operate(); IProduct <Plane> planePartProduct = planeFactory.Create <Rudder>(); planePartProduct.Operate(); }
static void Main(string[] args) { var controltower = new JasionkaControlTower(); FlyingMachine helicopter = new Helicopter(); FlyingMachine airBus = new Airbus(); FlyingMachine boeing = new Boeing(); controltower.Register(helicopter); controltower.Register(airBus); controltower.Register(boeing); helicopter.SendControlMessage(); Console.WriteLine(); airBus.SendControlMessage(); Console.WriteLine(); boeing.SendControlMessage(); Console.Read(); }
//Method used to add new flights. private static void NewFlights() { using (var ctx = new TodoContext()) { FlightFactory flightFactory = new BoeingFactory(new PreSaleState()); Boeing boeing = (Boeing)flightFactory.CreateFlight(); //Check what is the state of the journey CheckState(boeing); //open the sales of this particular boeing boeing.OpenSales("MTX", "BKK", new DateTime(2020, 07, 1), 199); //check the state after the opening of the sales CheckState(boeing); ctx.FlightSet.Add(boeing); ctx.SaveChanges(); } }
static void Main(string[] args) { Airbus A340 = new Airbus(); A340.Agirlik = 126000; A340.Uzunluk = 59.39; A340.Yukseklik = 16.74; A340.Model = "Airbus A340"; A340.ModelGoster(); A340.TeknikBilgiGoster(); Console.WriteLine("------------------------------"); Boeing B747 = new Boeing(); B747.Agirlik = 180985; B747.Uzunluk = 70.67; B747.Yukseklik = 19.41; B747.Model = "Boeing B747"; B747.ModelGoster(); B747.TeknikBilgiGoster(); Console.ReadKey(); }