public void getPassengerPlaneWithMaxCapacityTest() { Airport airport = new Airport(planes); PassengerPlane expectedPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); Assert.assertTrue(expectedPlaneWithMaxPassengersCapacity.Equals(planeWithMaxPassengerCapacity)); }
public void TrueEqualTest() { PassengerPlane firstPlane = new PassengerPlane("model", 999, 9999, 99999, 123); PassengerPlane secondPlane = new PassengerPlane("model", 999, 9999, 99999, 123); Assert.AreEqual(firstPlane, secondPlane); }
private void AddToTemlatePlane(Plane plane) { numberLabel.Text = plane.Number.ToString(); markLabel.Text = plane.Mark; releaseYearLabel.Text = plane.ReleaseYear.ToString(); if (plane is PassengerPlane) { PassengerPlane passPlane = plane as PassengerPlane; labelType.Text = "Passenger Plane"; planeAirLinelabel.Text = passPlane.AirlineName; planeSeatsCountlabel.Text = passPlane.SeatsCount.ToString(); panelPassenger.Visible = true; } if (plane is MilitaryPlane) { MilitaryPlane millPlane = plane as MilitaryPlane; labelType.Text = "Military Plane"; crewMembersListBox.DataSource = new BindingList <string>(millPlane.CrewMembers); capacityPlaneLabel.Text = millPlane.Capacity.ToString(); panelMilitary.Visible = true; } if (plane.Creator != null) { creatorNameLabel.Text = plane.Creator.Name; creatorYearLabel.Text = plane.Creator.FoundationYear.ToString(); creatorCountryLabel.Text = plane.Creator.Country; planeTypeListBox.DataSource = plane.Creator.AirPlanesTypes; panelCreator.Visible = true; } }
public void IsNotEqualsMilitaryPlane() { PassengerPlane actualResultPlane = planeWithMaxPassengersCapacity.First() as PassengerPlane; MilitaryPlane expectedResultPlane = transportMilitaryPlane.First() as MilitaryPlane; Assert.AreNotEqual(actualResultPlane, expectedResultPlane); }
public void SetTemplate(Plane plane) { numberTextBox.Text = plane.Number.ToString(); markTextBox.Text = plane.Mark; releaseYearTextBox.Text = plane.ReleaseYear.ToString(); if (plane is PassengerPlane) { PassengerPlane passPlane = plane as PassengerPlane; passengerPanel.Visible = true; textBoxAirlineName.Text = passPlane.AirlineName; textBoxSeatsCount.Text = passPlane.SeatsCount.ToString(); } if (plane is MilitaryPlane) { MilitaryPlane millPlane = plane as MilitaryPlane; militaryPanel.Visible = true; _crewMembers = new BindingList <string>(millPlane.CrewMembers); crewMembersListBox.DataSource = _crewMembers; capacityTextBox.Text = millPlane.Capacity.ToString(); } if (plane.Creator != null) { creatorPanel.Visible = true; allowCreatorCheckBox.Checked = true; creatorNameTextBox.Text = plane.Creator.Name; creatorCountryTextBox.Text = plane.Creator.Country; creatorFoundationYearTextBox.Text = plane.Creator.FoundationYear.ToString(); _planesTypes = new BindingList <string>(plane.Creator.AirPlanesTypes); planeTypeListBox.DataSource = _planesTypes; } }
public PassengerPlane GetPassengerPlaneWithMaxPassengersCapacity() { PassengerPlane expectedPlaneWithMaxPassengersCapacity = this.GetPassengerPlaneWithMaxPassengersCapacity(); List <PassengerPlane> passengerPlanes = GetPassengersPlanes(); return(passengerPlanes.Aggregate((w, x) => w.PassengersCapacityIs() > x.PassengersCapacityIs() ? w : x)); }
public void GetPassengerPlaneWithMaxPassengersCapacity() { Airport airport = new Airport(planes); PassengerPlane passengerPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); Assert.IsTrue(passengerPlaneWithMaxPassengersCapacity.GetHashCode() == expectedPassengerplaneWithMaxPassengerCapacity.GetHashCode(), "Wrong passenger capacity"); }
public void ExceedsLimitMaxPassengersCapacity() { Airport airport = new Airport(planes); PassengerPlane expectedPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); Assert.IsTrue(airport.GetPassengerPlaneWithMaxPassengersCapacity().GetPassengersCapacity() <= new PassengerPlane("Boeing-747", 980, 16100, 70500, 242).GetPassengersCapacity()); }
public static void Main() { //------------------------------------------------------------------------ // Build a collection of all vehicles that fly // With a single `foreach`, have each vehicle Fly() PassengerPlane plane1 = new PassengerPlane(); PrivateJet plane2 = new PrivateJet(); Spaceship plane3 = new Spaceship(); //creat a list of planes var planes = new List <Aircraft>(); planes.Add(plane1); planes.Add(plane2); planes.Add(plane3); //loop over the list with a foreach and call method Fly() for each one foreach (var plane in planes) { plane.Fly(); } //-------------------------------------------------------------------------- //------------------------------------------------------------------------ // Build a collection of all vehicles that operate on roads // With a single `foreach`, have each road vehicle Drive() NissanLeaf car1 = new NissanLeaf(); NissanKicks car2 = new NissanKicks(); NissanRogue car3 = new NissanRogue(); //creat a list of cars var cars = new List <Car>(); cars.Add(car1); cars.Add(car2); cars.Add(car3); //loop over the list with a foreach and call method Drive() for each one foreach (var car in cars) { car.Drive(); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Build a collection of all vehicles that operate on water // With a single `foreach`, have each water vehicle Drive() MotorBoat boat1 = new MotorBoat(); RowBoat boat2 = new RowBoat(); Yacht boat3 = new Yacht(); //creat a list of boat var boats = new List <Watercraft>(); boats.Add(boat1); boats.Add(boat2); boats.Add(boat3); //loop over the list with a foreach and call method Drive() for each one foreach (var boat in boats) { boat.Drive(); } //-------------------------------------------------------------------------- }
static void Main(string[] args) { Airplane a1 = new PassengerPlane(new Airbus()); a1.Fly(); Airplane a2 = new PassengerPlane(new Boeing()); a2.Fly(); Airplane a3 = new PassengerPlane(new MD()); a3.Fly(); Airplane a4 = new CargoPlane(new Airbus()); a4.Fly(); Airplane a5 = new CargoPlane(new Boeing()); a5.Fly(); Airplane a6 = new CargoPlane(new MD()); a6.Fly(); Console.ReadLine(); }
public void PlaneWithMaxPassengersCapacityIsBoeing747() { Airport airport = new Airport(planes); PassengerPlane expectedPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); Assert.Equals(expectedPlaneWithMaxPassengersCapacity, planeWithMaxPassengerCapacity); }
public void FalseFifthEqualTest() { PassengerPlane firstPlane = new PassengerPlane("model", 999, 9999, 99999, 123); PassengerPlane secondPlane = new PassengerPlane("model", 999, 9999, 99999, 1234); Assert.AreNotEqual(firstPlane, secondPlane); }
public void IsEqualsPassengerPlane() { PassengerPlane actualResultPlane = planeSimilarToPlaneWithMaxPassengersCapacity.First() as PassengerPlane; PassengerPlane expectedResultPlane = planeWithMaxPassengersCapacity.First() as PassengerPlane; Assert.AreEqual(actualResultPlane, expectedResultPlane); }
public void HasTopSecretPassengerPlane() { Airport airport = new Airport(planes); PassengerPlane actualResultPlane = airport.GetSecretPassengerPlanes().First(); PassengerPlane expectedResultPlane = planeWithMaxPassengersCapacity.First() as PassengerPlane; Assert.IsTrue(actualResultPlane.IsEqualByHash(expectedResultPlane)); }
public void IsPlaneHasMaxPassangerCapacityTest() { Airport airport = new Airport(planes); PassengerPlane expectedPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); bool expected = expectedPlaneWithMaxPassengersCapacity.Equals(planeWithMaxPassengerCapacity); Assert.IsTrue(expected); }
public void HasNoMilitaryTransportPlane() { Airport airport = new Airport(planes); PassengerPlane actualResultPlane = airport.GetSecretPassengerPlanes().First(); MilitaryPlane expectedResultPlane = transportMilitaryPlane.First(); Assert.IsFalse(actualResultPlane.IsEqualByHash(expectedResultPlane)); }
public void GetPassengerPlaneWithMaxPassengersCapacityTest() { var airport = new Airport(_planes); var planeWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); PassengerPlane expectedPlaneWithMaxPassengersCapacity = new PassengerPlane("Boeing-747", 980, 16100, 70500, 242); Assert.True(expectedPlaneWithMaxPassengersCapacity.Equals(planeWithMaxPassengersCapacity)); }
public void HasCorrectPassengerPlaneWithMaxPassengersCapacity() { Airport airport = new Airport(planes); PassengerPlane actualResultPlane = airport.GetPassengerPlaneWithMaxPassengersCapacity(); PassengerPlane expectedResultPlane = (PassengerPlane)planeWithMaxPassengersCapacity.First(); Assert.IsTrue(actualResultPlane.IsEqualByHash(expectedResultPlane)); }
public void ComparePlanesWithMaxPassengerCapacity() { MixedAirport airport = new MixedAirport { Planes = planes }; PassengerAirport passengerAirport = new PassengerAirport { Planes = airport.GetPassengersPlanes() }; PassengerPlane expectedPlaneWithMaxPassengersCapacity = passengerAirport.GetPlaneWithMaxPassengersCapacity(); Assert.That(planeWithMaxPassengerCapacity, Is.EqualTo(expectedPlaneWithMaxPassengersCapacity)); }
/// <summary> /// Odczytuje samolot o zadanym id z pliku xml z samolotami /// </summary> static public Plane readFromFile(int id) { XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Resources.DefinedPlanes); Plane loadedPlane; XmlNodeList planeNodes = xDoc.SelectNodes("Planes/Plane"); foreach (XmlNode node in planeNodes) { if (Int32.Parse(node.Attributes.GetNamedItem("id").Value) == id) { string type = node.SelectSingleNode("Type").InnerText; if (type == "PassengerPlane") { loadedPlane = new PassengerPlane(); ((PassengerPlane)loadedPlane).setMaxNumberOfPassengers(Int32.Parse(node.SelectSingleNode("MaxPassengers").InnerText)); } else if (type == "MilitaryPlane") { loadedPlane = new MilitaryPlane(); ((MilitaryPlane)loadedPlane).setMaxAmmo(Int32.Parse(node.SelectSingleNode("MaxAmmo").InnerText)); ((MilitaryPlane)loadedPlane).setWeaponType(node.SelectSingleNode("WeaponType").InnerText); } else if (type == "TransportPlane") { loadedPlane = new TransportPlane(); ((TransportPlane)loadedPlane).setMaxStorageCapacity(Int32.Parse(node.SelectSingleNode("MaxStorage").InnerText)); } else { return(null); } loadedPlane.setModel(node.SelectSingleNode("Model").InnerText); loadedPlane.setMaxFuelLevel(Int32.Parse(node.SelectSingleNode("MaxFuelLevel").InnerText)); loadedPlane.setFuelUsage(Int32.Parse(node.SelectSingleNode("FuelUsage").InnerText)); loadedPlane.setTakeoffTime(Int32.Parse(node.SelectSingleNode("TakeoffInterval").InnerText)); loadedPlane.setPlaneImage(node.SelectSingleNode("Image").InnerText); return(loadedPlane); } } return(null); }
public MainForm() { InitializeComponent(); _planeList = new BindingList <Plane>(); PassengerPlane pl = new PassengerPlane { Number = 1, Mark = "Boing", Creator = null, AirlineName = "united", SeatsCount = 250, ReleaseYear = 2010 }; PassengerPlane pl1 = new PassengerPlane { Number = 3, Mark = "aBoing", Creator = null, AirlineName = "united", SeatsCount = 250, ReleaseYear = 2010 }; PassengerPlane pl2 = new PassengerPlane { Number = 4, Mark = "abBoing", Creator = null, AirlineName = "united", SeatsCount = 250, ReleaseYear = 2010 }; listAirPlane.DataSource = _planeList; _planeList.Add(pl); _planeList.Add(pl1); _planeList.Add(pl2); }
private void addButton_Click(object sender, EventArgs e) { AirPlaneCreator creator = null; if (allowCreatorCheckBox.Checked) { creator = new AirPlaneCreator { Name = creatorNameTextBox.Text, Country = creatorCountryTextBox.Text, AirPlanesTypes = _planesTypes.ToList(), FoundationYear = Convert.ToInt32(creatorFoundationYearTextBox.Text) }; } if (passengerPlaneRadioButton.Checked) { PassengerPlane newPasPlane = new PassengerPlane { Number = Convert.ToInt32(numberTextBox.Text), Mark = markTextBox.Text, AirlineName = airlineNameTextBox.Text, Creator = creator, ReleaseYear = Convert.ToInt32(releaseYearTextBox.Text), SeatsCount = Convert.ToInt32(seatsCountTextBox.Text) }; _planesList.Add(newPasPlane); } if (militaryPlaneRadioButton.Checked) { MilitaryPlane newMilPlane = new MilitaryPlane { Number = Convert.ToInt32(numberTextBox.Text), Mark = markTextBox.Text, Creator = creator, ReleaseYear = Convert.ToInt32(releaseYearTextBox.Text), Capacity = Convert.ToInt32(capacityTextBox.Text), CrewMembers = _crewMembers.ToList() }; _planesList.Add(newMilPlane); } this.Close(); }
public AirportTest() { planes = new List <Plane>() { new PassengerPlane("Boeing-737", 900, 12000, 60500, 164), new PassengerPlane("Boeing-737-800", 940, 12300, 63870, 192), new PassengerPlane("Boeing-747", 980, 16100, 70500, 242), new PassengerPlane("Airbus A320", 930, 11800, 65500, 188), new PassengerPlane("Airbus A330", 990, 14800, 80500, 222), new PassengerPlane("Embraer 190", 870, 8100, 30800, 64), new PassengerPlane("Sukhoi Superjet 100", 870, 11500, 50500, 140), new PassengerPlane("Bombardier CS300", 920, 11000, 60700, 196), new MilitaryPlane("B-1B Lancer", 1050, 21000, 80000, MilitaryType.BOMBER), new MilitaryPlane("B-2 Spirit", 1030, 22000, 70000, MilitaryType.BOMBER), new MilitaryPlane("B-52 Stratofortress", 1000, 20000, 80000, MilitaryType.BOMBER), new MilitaryPlane("F-15", 1500, 12000, 10000, MilitaryType.FIGHTER), new MilitaryPlane("F-22", 1550, 13000, 11000, MilitaryType.FIGHTER), new MilitaryPlane("C-130 Hercules", 650, 5000, 110000, MilitaryType.TRANSPORT) }; airport = new Airport(planes); planeWithMaxPassengerCapacity = new PassengerPlane("Boeing-747", 980, 16100, 70500, 242); }
private void buttonCreateInHangar_Click(object sender, EventArgs e) { if (!validateData()) { return; } Plane factoriedPlane; if (currentFactoring == PlaneType.Passenger) { factoriedPlane = new PassengerPlane(); ((PassengerPlane)factoriedPlane).setMaxNumberOfPassengers(Int32.Parse(textBoxSpecific.Text)); } else if (currentFactoring == PlaneType.Transport) { factoriedPlane = new TransportPlane(); ((TransportPlane)factoriedPlane).setMaxStorageCapacity(Int32.Parse(textBoxSpecific.Text)); } else { factoriedPlane = new MilitaryPlane(); ((MilitaryPlane)factoriedPlane).setWeaponType(textBoxWeaponType.Text); ((MilitaryPlane)factoriedPlane).setMaxAmmo(Int32.Parse(textBoxSpecific.Text)); } factoriedPlane.setPlaneImage(chosenImageName); factoriedPlane.setModel(textBoxModel.Text); factoriedPlane.setFuelUsage(Int32.Parse(textBoxFuelUsage.Text)); factoriedPlane.setMaxFuelLevel(Int32.Parse(textBoxMaxFuelLevel.Text)); factoriedPlane.setTakeoffTime(Int32.Parse(comboBox1.Text)); factoriedPlane.setAfterTechnicalInspection(false); AirportManager.getInstance().getHangar().addToHangar(factoriedPlane); hideFactoryPanel(); resetControls(); handleAppWindow.refreshBtnPlaneFactory(); }
static void RunDemo() { IAirplane plane1 = new CargoPlane { Id = 1, Carrying = 100, FuelConsumption = 25, Range = 40 }; IAirplane plane2 = new CargoPlane { Id = 2, Carrying = 140, FuelConsumption = 30, Range = 35 }; IAirplane plane3 = new PassengerPlane { Id = 3, Carrying = 70, FuelConsumption = 20, Range = 50 }; IAirplane plane4 = new SportPlane { Id = 4, Carrying = 20, FuelConsumption = 10, Range = 20 }; Company company = new Company(); company.RegisterPlain(plane1); company.RegisterPlain(plane2); company.RegisterPlain(plane3); company.RegisterPlain(plane4); Console.WriteLine(plane2.Fly()); Console.WriteLine(company.UnregisterPlane(5)); var list1 = company.OrderByFlyingDistance(); foreach (var t in list1) { Console.WriteLine("Plane with Id " + t.Id); } var list2 = company.FiltrationByFuelConsumption(15, 28); foreach (var t in list2) { Console.WriteLine("Plane with Id " + t.Id); } }
public void StartShop(PassengerPlane m_plane) { m_shop.StartShop(m_plane); }
private IPlane CreatePlane(string[] config) { IPlane plane = null; var dict = config.Where(s => !string.IsNullOrEmpty(s)) .Select(s => s.Split('=')) .Where(s => s.Length > 1) .Select(s => new string[2] { s[0].Trim(), s[1].Trim() }); //.ToDictionary(k => k[0].Trim(), v => v[1].Trim()); string number = string.Empty; string manufacture = string.Empty; int flightRange = 0; double fuelTankSize = 0; int cargoCapacity = 0; int passengersCapacity = 0; foreach (string[] s in dict) { switch (s[0].ToUpper()) { case "NUMBER": number = s[1]; break; case "MANUFACTURE": manufacture = s[1]; break; case "FLIGHTRANGE": Int32.TryParse(s[1], out flightRange); break; case "FUELTANKSIZE": double.TryParse(s[1], out fuelTankSize); break; case "CARGOCAPACITY": Int32.TryParse(s[1], out cargoCapacity); break; case "PASSENGERSCAPACITY": Int32.TryParse(s[1], out passengersCapacity); break; default: break; } } if (flightRange > 0 && fuelTankSize > 0) { if (cargoCapacity > 0) { if (passengersCapacity > 0) { plane = new CargoPassengerPlane(flightRange, fuelTankSize, manufacture, cargoCapacity, passengersCapacity); } else { plane = new CargoPlane(flightRange, fuelTankSize, manufacture, cargoCapacity); } } else if (passengersCapacity > 0) { plane = new PassengerPlane(flightRange, fuelTankSize, manufacture, passengersCapacity); } else { plane = new Plane(flightRange, fuelTankSize, manufacture); } plane.Number = number; } return(plane); }
public void GetPassengerPlaneWithMaxCapacityReturnedTrue() { PassengerPlane expectedPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); }
public void GetPassengersCapacityTest() { PassengerPlane passengerPlane = new PassengerPlane("model", 999, 9999, 99999, 123); Assert.AreEqual(123, passengerPlane.GetPassengersCapacity()); }
public void MyTest2() { Airport airport = new Airport(planes); PassengerPlane expectedPlaneWithMaxPassengersCapacity = airport.GetPassengerPlaneWithMaxPassengersCapacity(); }