public void IsNotEqualsMilitaryPlane() { PassengerPlane actualResultPlane = planeWithMaxPassengersCapacity.First() as PassengerPlane; MilitaryPlane expectedResultPlane = transportMilitaryPlane.First() as MilitaryPlane; Assert.AreNotEqual(actualResultPlane, expectedResultPlane); }
public void IsEqualsMilitaryPlane() { MilitaryPlane actualResultPlane = planeSimilarToTransportMilitaryPlane.First() as MilitaryPlane; MilitaryPlane expectedResultPlane = transportMilitaryPlane.First() as MilitaryPlane; Assert.AreEqual(actualResultPlane, expectedResultPlane); }
public void TrueEqualTest() { MilitaryPlane firstPlane = new MilitaryPlane("model", 999, 9999, 99999, Aircompany.Models.MilitaryAirplaneType.Bomber); MilitaryPlane secondPlane = new MilitaryPlane("model", 999, 9999, 99999, Aircompany.Models.MilitaryAirplaneType.Bomber); Assert.AreEqual(firstPlane, secondPlane); }
public void FalseFifthEqualTest() { MilitaryPlane firstPlane = new MilitaryPlane("model", 999, 9999, 99999, Aircompany.Models.MilitaryAirplaneType.Bomber); MilitaryPlane secondPlane = new MilitaryPlane("model", 999, 9999, 99999, Aircompany.Models.MilitaryAirplaneType.Transport); Assert.AreNotEqual(firstPlane, secondPlane); }
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; } }
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 HasNoMilitaryTransportPlane() { Airport airport = new Airport(planes); PassengerPlane actualResultPlane = airport.GetSecretPassengerPlanes().First(); MilitaryPlane expectedResultPlane = transportMilitaryPlane.First(); Assert.IsFalse(actualResultPlane.IsEqualByHash(expectedResultPlane)); }
public void HasMilitaryTransportPlane() { Airport airport = new Airport(planes); MilitaryPlane actualResultPlane = airport.GetTransportMilitaryPlanes().First(); MilitaryPlane expectedResultPlane = transportMilitaryPlane.First(); Assert.IsTrue(actualResultPlane.IsEqualByHash(expectedResultPlane)); }
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(); }
/// <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 List <MilitaryPlane> GetTransportMilitaryPlanes() { List <MilitaryPlane> transportMilitaryPlanes = new List <MilitaryPlane>(); for (int i = 0; i < GetMilitaryPlanes().Count; i++) { MilitaryPlane plane = GetMilitaryPlanes()[i]; if (plane.GetPlaneType() == MilitaryType.TRANSPORT) { transportMilitaryPlanes.Add(plane); } } return(transportMilitaryPlanes); }
public List <MilitaryPlane> GetTransportMilitaryPlanes() { List <MilitaryPlane> transportMilitaryPlanes = new List <MilitaryPlane>(); List <MilitaryPlane> militaryPlanes = GetMilitaryPlanes(); for (int i = 0; i < militaryPlanes.Count; i++) { MilitaryPlane plane = militaryPlanes[i]; if (plane.MilitaryPlaneType == MilitaryPlaneType.Transport) { transportMilitaryPlanes.Add(plane); } } return(transportMilitaryPlanes); }
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(); }
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(); }
public void GetPlaneTypeTest() { MilitaryPlane militaryPlane = new MilitaryPlane("model", 999, 9999, 99999, Aircompany.Models.MilitaryAirplaneType.Bomber); Assert.AreEqual(Aircompany.Models.MilitaryAirplaneType.Bomber, militaryPlane.GetPlaneType()); }