// Use this for initialization void Start() { timeToAct += turnTime; airplane = new Airplane (); grid = new GameObject[numCubesX, numCubesY]; //setting airplane location airplane.x = 0; airplane.y = 8; //setting cargo info airplane.cargo = 0; airplane.cargoCapacity = 90; //spawn all the grid for (int x = 0; x < numCubesX; x++) { for (int y = 0; y < numCubesY; y++) { grid[x,y] = (GameObject) Instantiate (cubePrefab, new Vector3(x*2 - 14, y*2 - 8, 10), Quaternion.identity); grid[x,y].GetComponent<CubeBehavior>().x = x; grid[x,y].GetComponent<CubeBehavior>().y = y; } } //set airplane as red grid [0, 8].GetComponent<Renderer>().material.color = Color.red; //set depot as black grid [15, 0].GetComponent<Renderer>().material.color = Color.black; }
public void SortingForwarderTest1() { List<IRole> roles = new List<IRole>(); roles.Add(new LoaderRole()); Personnel p1 = new Personnel(2, roles); List<Personnel> pl = new List<Personnel>(); PersonnelController pc = new PersonnelController(pl); List<IProblem> problems = new List<IProblem>(); problems.Add(new Stuck(0, pc)); Airplane ap = new Airplane(problems, 2); ILuggageQueue queue = new FIFOQueue(); bool pass1 = queue.Count() == 0; queue.enqueueLuggage(1, new LuggageBag(ap)); bool pass2 = queue.Count() == 1; List<IComponent> nextComponents = new List<IComponent>(); nextComponents.Add(ap); SortingForwarder s = new SortingForwarder(queue,nextComponents); Thread.Sleep(1000); s.processLuggage(new LuggageBag(ap)); bool pass3 = queue.Count() == 0; Assert.IsTrue(pass1); Assert.IsTrue(pass2); Assert.IsTrue(pass3); }
private void Form1_Load(object sender, EventArgs e) { bsP.ListChanged += new ListChangedEventHandler(bsP_ListChanged); // Create some example data. Airplane a1, a2, a3; bsA.Add(a1 = new Airplane("Boeing 747", 800)); bsA.Add(a2 = new Airplane("Airbus A380", 1023)); bsA.Add(a3 = new Airplane("Cessna 162", 67)); a1.Passengers.Add(new Passenger("Joe Shmuck")); a1.Passengers.Add(new Passenger("Jack B. Nimble")); a1.Passengers.Add(new Passenger("Jib Jab")); a2.Passengers.Add(new Passenger("Jackie Tyler")); a2.Passengers.Add(new Passenger("Jane Doe")); a3.Passengers.Add(new Passenger("John Smith")); // Set up data binding for the parent Airplanes grid.DataSource = bsA; grid.AutoGenerateColumns = true; txtModel.DataBindings.Add("Text", bsA, "Model"); // Set up data binding for the child Passengers bsP.DataSource = bsA; // connect the two sources bsP.DataMember = "Passengers"; lstPassengers.DataSource = bsP; lstPassengers.DisplayMember = "Name"; txtName.DataBindings.Add("Text", bsP, "Name"); // Allow the user to add rows ((BindingList<Airplane>)bsA.List).AllowNew = true; ((BindingList<Airplane>)bsA.List).AllowRemove = true; }
public void testLuggageBagConstructor() { List<IProblem> problems = new List<IProblem>(); int id= 0; IComponent c_destination = new Airplane(problems, id); LuggageBag lb = new LuggageBag(c_destination); Assert.AreEqual(lb.destination, c_destination); Assert.AreEqual(c_destination.getSinks().Count, 1); }
public void testAirplaneConstructor() { List<IProblem> problems = new List<IProblem>(); int id= 0; Airplane ap = new Airplane(problems, id); // Constructor() Assert.AreEqual(ap.name, "Airplane number: "+id.ToString()); Assert.AreEqual(ap.initialized, true); Assert.AreEqual(ap.stuck, false); IComponent destination = ap; LuggageBag lb = new LuggageBag(destination); // Check count() and enqueluggage with problem and without problem List<Personnel> plist = new List<Personnel>(); List<IRole> roles = new List<IRole>(); roles.Add(new StuckLuggageRole()); Personnel p1 = new Personnel(1, roles); plist.Add(p1); PersonnelController pc = new PersonnelController(plist); Stuck s = new Stuck(0, pc); problems.Add(s); ap.EnqueueLuggage(lb); Thread.Sleep(1000); Assert.AreEqual(0, ap.Count()); s = new Stuck(100, pc); problems.Add(s); ap.EnqueueLuggage(lb); Assert.AreEqual(1, ap.Count()); //DequeLuggage() //ap.DequeueLuggage(); //Assert.AreEqual(ap.Count(), 0); //AddNextComponent() try { ap.addNextComponent(ap); } catch (NotImplementedException) { Assert.IsTrue(true); } //InAndOutCounters() Assert.AreEqual(ap.InAndOutCounters().Item1, 2); //GetSinks() //Assert.AreEqual(ap.getSinks(), ); Assert.AreEqual(ap.getSinks().Count, 1); //Assert.AreEqual(ap.getSinks().ToString(), "Airplane number: 0"); }
public void FreightAirplaneEquals(int flightDistance) { Airplane airplaneEquals = new Airplane(tailNumber, flightDistance); bool expectedResult = this.flightDistance.Equals(flightDistance); bool actualResult = airplane.Equals(airplaneEquals); Assert.That(actualResult, Is.EqualTo(expectedResult)); airplaneEquals = null; }
public void FreightAirplaneCompareTo(int flightDistance) { Airplane airplaneCompareTo = new Airplane(tailNumber, flightDistance); int expectedResult = this.flightDistance.CompareTo(flightDistance); int actualResult = airplane.CompareTo(airplaneCompareTo); Assert.That(actualResult, Is.EqualTo(expectedResult)); airplaneCompareTo = null; }
// Use this for initialization void Start() { ap1 = new Airplane () ; ap1.x = startX; ap1.y = startY; ap1.destX = startX; ap1.destY = startY; ap1.cargoHold = 0; for (int y = 0; y < 9; y++) { for (int x = 0; x < 16;x++) { SpawnCube (x,y); } } }
// Use this for initialization void Start() { allCubes = new GameObject[gridWidth, gridHeight]; for (int x = 0; x < gridWidth; x++) { for (int y = 0; y <gridHeight; y++) { allCubes[x,y] = (GameObject) Instantiate(cubePrefab, new Vector3(x*2 - 14, y*2 - 8, 10), Quaternion.identity); allCubes[x,y].GetComponent<CubeBehavior>().x = x; allCubes[x,y].GetComponent<CubeBehavior>().y = y; } } airplane = new Airplane(); airplane.x = 0; airplane.y = 8; allCubes[0,8].GetComponent<Renderer>().material.color = Color.red; }
// Use this for initialization void Start() { airplane = new Airplane (); for (int h = 0; h < numRows; h++) { for (int i = 0; i < numCubes; i++) { allCubes [i,h] = (GameObject)Instantiate (cubePrefab, new Vector3 (i * 2 - 14, h * 2, 10), Quaternion.identity); // these lines turn the location of the spanwed cubes into the x and y values used in CubeBehavior allCubes [i,h].GetComponent<CubeBehavior>().x = i; allCubes [i,h].GetComponent<CubeBehavior>().y = h; } } // tells the airplane to spawn in the upper left airplane.x = 0; airplane.y = 8; allCubes [0,8].GetComponent<Renderer>().material.color = Color.red; }
// Use this for initialization void Start() { airplane = new Airplane (); airplane.x = 0; airplane.z = numCubes - 1; allCubes = new GameObject[numbCubes, numCubes]; for (int x = 0; x < numbCubes; x++) { for (int z = 0; z < numCubes; z++) { allCubes [x,z] = (GameObject)Instantiate (cubePrefab, new Vector3 (x * 2 -14, z * 2 - 14, 10), Quaternion.identity); allCubes [x,z].GetComponent<CubeBehavior>().x = x; allCubes [x,z].GetComponent<CubeBehavior>().z = z; allCubes [x,z].GetComponent<CubeBehavior>().GameController = this; } } allCubes[0,numCubes - 1].GetComponent<Renderer>().material.color = Color.red; }
void Start() { airplane = new Airplane(); //previously defined array now has stuff inside it, so it's a new Gameobject with [16] cubes allCubes = new GameObject[numCubesWide, numCubesTall]; //in for loops, first param is start, second is end, third is incrementation //++ means add 1 each subsequent loop for (int x = 0; x < numCubesWide; x++) { for (int y = 0; y < numCubesTall; y++) { //declared the array earlier in the code, assigning it now //instantiates 16 cubes and then 9 rows of that allCubes[x, y] = (GameObject)Instantiate(CubePrefab, new Vector3(x * 2, y * 2, 0), Quaternion.identity); //allCubes[x,y] references the exact place of the cube we just used, GetComponent gets the info on which script, and .x says the x value of that component allCubes[x, y].GetComponent<CubeBehavior>().x = x; allCubes[x, y].GetComponent<CubeBehavior>().y = y; } } //after unity is done making the grid, it turns the first one red //allCubes[0, numCubesTall - 1].GetComponent<Renderer>().material.color = Color.red; //creates the airplane airplane.x = 0; airplane.y = 8; //same place as the red square..[i,j] allCubes[0, numCubesTall - 1].GetComponent<Renderer>().material.color = Color.red; //instantiate() takes parameters: the name of the object/prefab, the place, and rotation //i replaces the x value in this context because the x value of the cubes are increasing (will place them side by side?) //allCubes[i] = allCubes[0] and increments with the for loop, placing each instantiation into a new array slot [1], [2]... // allCubes[i,j] = (GameObject) Instantiate (CubePrefab, new Vector3(i*2, 0, 0), Quaternion.identity); //make a timer //this timer takes place every 1.5 seconds timeToAct = turnLength; }
public void AirpnAireplaneFlyUp() { //Arrange Airplane ap = this.Airplane; //act ap.StartEngine(); string firstTakeoff = ap.TakeOff(); int defaultHeight = ap.CurrentAltitude; ap.FlyUp(); int firstAlt = ap.CurrentAltitude; ap.FlyUp(40000); int secondAlt = ap.CurrentAltitude; //Assert Assert.AreEqual(defaultHeight, 0); Assert.AreEqual(firstAlt, 1000); Assert.AreEqual(secondAlt, 41000); }
public void Airplane_Constructor() { Type type = typeof(Airplane); Airplane airplane = (Airplane)Activator.CreateInstance(type, "ABC123", 2, 3); PropertyInfo prop = type.GetProperty("PlaneNumber"); Assert.AreEqual("ABC123", prop.GetValue(airplane), "Passed ABC123 into constructor and expected PlaneNumber property to hold 1"); prop = type.GetProperty("TotalFirstClassSeats"); Assert.AreEqual(2, prop.GetValue(airplane), "Passed 2 into constructor and expected TotalFirstClassSeats property to return 2"); prop = type.GetProperty("TotalCoachSeats"); Assert.AreEqual(3, prop.GetValue(airplane), "Passed 3 into constructor and expected TotalCoachSeats property to return 3"); prop = type.GetProperty("BookedFirstClassSeats"); Assert.AreEqual(0, prop.GetValue(airplane), "New planes should initially have 0 booked first class seats."); prop = type.GetProperty("BookedCoachSeats"); Assert.AreEqual(0, prop.GetValue(airplane), "New planes should initially have 0 booked coach seats."); }
void BusTransferResponse(PassengerTransferRequest req) { Airplane plane = airplanes[req.PlaneId]; lock (plane) { if (req.Action == TransferAction.Take) { mqClient.Send(queuesTo[Component.Bus], new PassengersTransfer() { BusId = req.BusId, PassengerCount = req.PassengersCount }); plane.Passengers -= req.PassengersCount; } else { plane.Passengers += req.PassengersCount; } } }
public Task <bool> buyAirplane(Airplane airplane) { User user = cache.getObject <User>(CacheKeys.USER); if (user == null) { return(Task.Run(() => false)); } Task <BuyAirplaneResponse> buyTask = apiProvider.post <BuyAirplaneResponse>( ApiEndPoints.BUY_AIRPLANE, new BuyAirplaneRequest(user.id, airplane.id, airplane.price) ); buyTask.GetAwaiter().OnCompleted(() => { if (buyTask != null && buyTask.Result != null && buyTask.Result.success) { cache.putObject(CacheKeys.USER, buyTask.Result.data.user); } }); return(buyTask.ContinueWith <bool>(task => task != null && task.Result != null && task.Result.success)); }
public void Handle(AirplaneCreateCommand message) { Airplane airplane = message.Airplane; if (!AirplaneValid(airplane)) { return; } // Validação de negocio // Nome Igual X // Persistencia airplane.SetDateInsert(); _airplaneRepository.Add(airplane); if (Commit()) { // _bus.RaiseEvent(new AirplaneCreateEvent(message.Airplane)); } }
static Airplane[] ReadAirplaneArray(int size) { Flights = new Airplane[size]; for (int i = 0; i < size; i++) { Flights[i] = new Airplane(); } for (int i = 0; i < size; i++) { Console.Write("Введiть мiсто початку польту:"); string StarCity = Console.ReadLine(); Console.Write("Введiть дату у форматi HH:MM YYYY-MM-DD :"); string StartDate = Console.ReadLine(); Console.Write("Введiть мiсто кiнця польту:"); string FinishCity = Console.ReadLine(); Console.Write("Введiть дату у форматi HH:MM YYYY-MM-DD :"); string FinishDate = Console.ReadLine(); Flights[i] = new Airplane(StarCity, StartDate, FinishCity, FinishDate); } return(Flights); }
public List <Seat> listSeats(Airplane airplane) { if (airplane == null) { throw new InvalidOperationException("[Reservation] Null Airplane"); } List <Seat> list = UnitOfWork.Seats.AsQueryable().Where(u => u.Airplane == airplane.Id).ToList(); try { if (list.FirstOrDefault() == null) { throw new InvalidOperationException("[Reservation] Airplane not registered"); } return(list); } catch (Exception ex) { throw ex; } }
public async Task <FlightResponse> AddFlight(FlightAddParameter flight, int airlineId) { var temp = await context.Airlines.Include(i => i.Flights).Include(i => i.Airplanes).FirstOrDefaultAsync(i => i.Id == airlineId); if (temp != null) { var tempFlight = new Flight(); tempFlight.StartLocation = flight.StartLocation; tempFlight.EndLocation = flight.EndLocation; tempFlight.EndDate = flight.EndDate; tempFlight.FlightClass = flight.FlightClass; tempFlight.StartDate = flight.StartDate; tempFlight.IsRoundTrip = flight.IsRoundTrip; tempFlight.Distance = flight.Distance; tempFlight.LoadInCabin = flight.LoadInCabin; tempFlight.WeightPricings = flight.WeightPricings; tempFlight.PaidExtras = flight.Extras; if (flight.IsRoundTrip) { tempFlight.StartDateBack = flight.StartDateBack; tempFlight.EndDateBack = flight.EndDateBack; } tempFlight.Price = flight.Price; var tempAirplane = new Airplane(); tempAirplane.Rows = flight.Airplane.Rows; tempAirplane.Columns = flight.Airplane.Columns; tempFlight.Airplane = tempAirplane; foreach (var a in flight.StopsLocations) { tempFlight.StopsLocations.Add(a); } temp.Flights.Add(tempFlight); temp.Airplanes.Add(tempFlight.Airplane); return(new FlightResponse(tempFlight)); } return(new FlightResponse("Airline does not exist.")); }
static void Main(string[] args) { Garage parking = new Garage(100); Car Audi = new Car { Make = CarModel.Audi, Model = "A4", Fuel = FuelType.Diesel }; Car BMW = new Car { Make = CarModel.BMW, Model = "X1", Fuel = FuelType.Petrol }; Car Skoda = new Car { Make = CarModel.Skoda, Model = "Fabia", Fuel = FuelType.LPG }; Airport airport = new Airport(20); Airplane Boeing = new Airplane { AirplaneModel = "Boeing", AirplaneType = AirplaneType.Combat }; Airplane WizzPlane = new Airplane { AirplaneModel = "WizzAirPlane", AirplaneType = AirplaneType.Civil }; Marina marina = new Marina(10); Boat sailboat = new Boat { BoatName = "Whistle", BoatType = BoatType.Sailboat }; parking.ParkTheVehicle(Audi); parking.ParkTheVehicle(BMW); parking.ParkTheVehicle(Skoda); airport.ParkTheAirplane(Boeing); airport.ParkTheAirplane(WizzPlane); marina.ParkTheVehicle(sailboat); parking.LeaveParking(Audi); airport.LeaveAirport(WizzPlane); }
static Airplane[] ReadAirplaneArray() { Console.WriteLine("Kilkist reisiv: "); int n = Convert.ToInt32(Console.ReadLine()); Airplane[] airplane = new Airplane[n]; string startCity, finishCity; int year_1, month_1, day_1, hours_1, minutes_1; int year_2, month_2, day_2, hours_2, minutes_2; for (int i = 0; i < n; i++) { Console.WriteLine($"Reis № {i + 1}"); Console.WriteLine("City start: "); startCity = Console.ReadLine(); Console.WriteLine("City end: "); finishCity = Console.ReadLine(); Console.WriteLine("Year, month, day, hour, minute start"); year_1 = Convert.ToInt32(Console.ReadLine()); month_1 = Convert.ToInt32(Console.ReadLine()); day_1 = Convert.ToInt32(Console.ReadLine()); hours_1 = Convert.ToInt32(Console.ReadLine()); minutes_1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Year, month, day, hour, minute end"); year_2 = Convert.ToInt32(Console.ReadLine()); month_2 = Convert.ToInt32(Console.ReadLine()); day_2 = Convert.ToInt32(Console.ReadLine()); hours_2 = Convert.ToInt32(Console.ReadLine()); minutes_2 = Convert.ToInt32(Console.ReadLine()); Date startDate = new Date(year_1, month_1, day_1, hours_1, minutes_1); Date finishDate = new Date(year_2, month_2, day_2, hours_2, minutes_2); airplane[i] = new Airplane(startCity, finishCity, startDate, finishDate); } return(airplane); }
public void AddPlane(Airplane airplane) { //add a reference to the plane's route airplane.currentAirRoute = m_Airport.IncomingRouteList.Find(x => x.airRouteID == airplane.currentAirRouteID); //check if the plane has entered circling, if so then change the state if (airplane.currentAirRoute.distanceKM - airplane.distanceAlongRoute < 0.0) { airplane.distanceAlongRoute = airplane.currentAirRoute.distanceKM; airplane.state = PlaneState.Circling; } //check if the plane has run out of fuel and crashed, if so then change the state if (airplane.fuel < 0) { airplane.fuel = 0; airplane.state = PlaneState.Crashed; } //add the plane to the queued (incoming) plane list m_Airport.planeQueuedList.Add(airplane); }
public async Task <ISingleResult <Airplane> > Execute(Airplane entity) { try { var validacao = await _validator.ValidarInclusao(entity); if (!validacao.Sucesso) { return(validacao); } entity.DataRegistro = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time")); await _repository.Add(entity); var sucesso = await Commit(); } catch (Exception) { return(new SingleResult <Domain.Models.Airplane>(MensagensNegocio.MSG07)); } return(new InclusaoResult <Domain.Models.Airplane>(entity)); }
public void Update(Airplane airplane) { if (Lerp) { Rotation = Quaternion.Lerp(Rotation, airplane.Rotation, 0.1f); } Vector3 campos = new Vector3(0f, 7.5f * airplane.Scale, 20f * airplane.Scale); campos = Vector3.Transform(campos, Matrix.CreateFromQuaternion(Rotation)); campos += airplane.Position; Vector3 camup = new Vector3(0, 1, 0); camup = Vector3.Transform(camup, Matrix.CreateFromQuaternion(Rotation)); this.Position = campos; this.UpDirection = camup; this.ViewMatrix = Matrix.CreateLookAt(Position, airplane.Position, UpDirection); this.ViewProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, AspectRatio, nearPlaneDistance, farPlaneDistance); }
public void SpawnPlane(bool drop, Vector3 passingTo) { if (AirplaneObject != null) { AirplaneSpawner spawner = GameObject.FindObjectOfType <AirplaneSpawner>(); if (spawner != null) { GameObject planeobj = UnitZ.gameNetwork.RequestSpawnObject(AirplaneObject, spawner.SpawnPoint(), Quaternion.identity); if (planeobj != null) { Debug.Log("Spawn plane"); planeobj.transform.LookAt(passingTo + (Vector3.up * planeobj.transform.position.y)); Airplane plane = planeobj.GetComponent <Airplane>(); if (plane != null) { plane.DropSupply = drop; plane.SetDrop(passingTo); } } } } }
static void Main(string[] args) { var endOfProcess = new QueuedHandler <CustomsDeclaration> (new NullHandler <CustomsDeclaration>("resident"), "end-of-process"); var customsAgent1 = new QueuedHandler <CustomsDeclaration>(new CustumsAgent(endOfProcess, "joe"), "agent-joe"); var customsAgent2 = new QueuedHandler <CustomsDeclaration>(new CustumsAgent(endOfProcess, "jack"), "agent-jack"); var customsAgent3 = new QueuedHandler <CustomsDeclaration>(new CustumsAgent(endOfProcess, "averell"), "agent-averell"); var customsAgentDispatcher = new RoundRobinDispatcher <CustomsDeclaration>(new[] { customsAgent1, customsAgent2, customsAgent3 }); var visitorHandler = new NullHandler <CustomsDeclaration>("visitor"); var residencyRouter = new QueuedHandler <CustomsDeclaration>(new ResidencyRouter(customsAgentDispatcher, visitorHandler), "residency-router"); residencyRouter.Start(); customsAgent1.Start(); customsAgent2.Start(); customsAgent3.Start(); var monitor = new Monitor(); monitor.Add(endOfProcess); monitor.Add(customsAgent1); monitor.Add(customsAgent2); monitor.Add(customsAgent3); monitor.Add(residencyRouter); monitor.Start(); var airplane = new Airplane(flight: "DC132", passengersCount: 666, handlesDeclaration: residencyRouter); var unload = new Task(airplane.Unload); unload.Start(); unload.Wait(); System.Console.ReadLine(); }
public void AirplaneDirection(string plane1Tag, int plane1X, int plane1Y, int plane1Alitude, string plane1Timestamp, string plane2Tag, int plane2X, int plane2Y, int plane2Alitude, string plane2Timestamp, double expected) { string format = "yyyyMMddHHmmssfff"; DateTime plane1Time = DateTime.ParseExact(plane1Timestamp, format, CultureInfo.InvariantCulture); DateTime plane2Time = DateTime.ParseExact(plane2Timestamp, format, CultureInfo.InvariantCulture); var airplanePing1 = new Airplane(plane1Tag, plane1X, plane1Y, plane1Alitude, plane1Time); var airplanePing2 = new Airplane(plane2Tag, plane2X, plane2Y, plane2Alitude, plane2Time); //Create list of Airplanes List <Airplane> airplanesList = new List <Airplane>(); airplanesList.Add(airplanePing1); //Unit under test/uut Calculator calculator = new Calculator(airplanesList); var actual = calculator.GetDirection(airplanePing2); Assert.AreEqual(actual, expected); }
private void fill_runways_page() { dataGridViewRunways.Rows.Clear(); foreach (KeyValuePair <int, Runway> runway in DataProcessing.runways) { string[] way = { "0", "1", "" }; way[0] = runway.Key.ToString(); if (runway.Value.countAirplanes() == 0) { way[1] = "free"; } else { Airplane now_plane = runway.Value.usingAirplane(DataProcessing.currentTime); if (now_plane.runwayNumber == 0) { way[1] = "free"; } else { if (!runway.Value.is_free(DataProcessing.currentTime)) { way[1] = "in use"; way[2] = now_plane.flight; if (DataProcessing.currentTime >= now_plane.applicationTime.AddMinutes(now_plane.getRequiredTimeInterval() - DataProcessing.maintenanceTime)) { way[1] = "maintenance"; way[2] = "after " + way[2]; } } else { way[1] = "free"; } } } dataGridViewRunways.Rows.Add(way); } }
public void AirplaneFlyDownCheck() { //arrange Airplane airplane = new Airplane(); //act - takeoff procedure airplane.Engine.Start(); airplane.TakeOff(); //act - flyup 10000 and down 5000 airplane.FlyUp(10000); airplane.FlyDown(5000); //assert - we should be at 5000 alt Assert.AreEqual(airplane.CurrentAltitude, 5000); //act - flydown to 0 airplane.FlyDown(5000); //assert - we should be at 0 alt Assert.AreEqual(airplane.CurrentAltitude, 0); }
public Airplane CreateAirplane() { int id; using (var r = new StreamReader(IdFilePath)) { id = Convert.ToInt32(r.ReadToEnd()) + 1; } using (var sw = new StreamWriter(IdFilePath, false)) { sw.Write(id); } var airplane = new Airplane(id); new Thread(() => { AddAirplaneToDB(airplane); }).Start(); return(airplane); }
public void ClassDefaultValues() { //Arrange Airplane a = airplane; ToyPlane tp = toyplane; Engine e = engine; //Act //Assert Airplane Assert.IsNotNull(a); Assert.AreEqual(a.maxAltitude, 41000); //Assert ToyPlane Assert.IsNotNull(tp); Assert.AreEqual(tp.maxAltitude, 50); Assert.AreEqual(tp.woundUp, false); //Assert Engine Assert.IsNotNull(e); Assert.AreEqual(e.isStarted, false); }
public bool CreateNewAirplane(int seats) { bool returnValue = false; var airplane = new Airplane { seats = seats }; _db.Airplanes.InsertOnSubmit(airplane); try { _db.SubmitChanges(); returnValue = true; } catch (SqlException) { returnValue = false; } return(returnValue); }
private Airplane GetSelectedAirplane() { // Neu khong co dong nao dang duoc chon thi tra ve null if (dgvAirplane.SelectedRows.Count != 1) { return(null); } // Neu co 1 dong dang duoc chon thi lay dong do ra DataGridViewRow row = dgvAirplane.SelectedRows[0]; // Lay du lieu trong dong do va tao ra mot Airplane moi Airplane airplane = new Airplane() { AirplaneCode = row.Cells["AirplaneCode"].Value.ToString(), TypeID = Convert.ToInt32(row.Cells["AirplaneTypeID"].Value), IsActive = Convert.ToBoolean(row.Cells["IsActive"].Value) }; // Tra Airplane vua tao ve return(airplane); }
public void RemoveElementTest() { //Arrange var capatity1 = Rnd.Next(1, 20); var garageHandler1 = new GarageHandler(); var garageHandler2 = new GarageHandler(); garageHandler1.CreateNewGarage(capatity1); garageHandler2.CreateNewGarage(capatity1); var test = new Airplane("Airplane2", "White", 3, 45, 23.56); garageHandler1.AddElement(test, test.GetType()); //act var res1 = garageHandler1.RemoveElement(test, test.GetType()); var res2 = garageHandler2.RemoveElement(test, test.GetType()); var res3 = garageHandler1.GetByRegNumber("Airplane2").FirstOrDefault(); //assert Assert.IsTrue(res1, $"Seems not have been remove in a garage witch it is"); Assert.IsFalse(res2, $"Seems have been remove in a garage witch it not is"); Assert.IsNull(res3, $"hmm test be inin garageHandler1, after remove"); }
public void should_be_return_invalid_rule_if_prisoner_are_alone_with_passengers() { var passengers = new List <IPassenger>() { new PassengerBuilder().IsPilot().Create(), new PassengerBuilder().IsCabinChief().Create(), new PassengerBuilder().IsPrisoner().Create(), new PassengerBuilder().IsStewardess().Create(), new PassengerBuilder().IsStewardess().Create(), new PassengerBuilder().IsFlightOfficer().Create(), new PassengerBuilder().IsFlightOfficer().Create() }; var airplane = new Airplane(passengers); var rulesManager = new RulesManager(airplane); rulesManager.ValidateRules(); rulesManager.IsValid().Should().BeFalse(); rulesManager.Errors.Any().Should().BeTrue(); }
public async Task <ActionResult <List <Airplane> > > Create( [FromBody] Airplane model, [FromServices] DataContext context ) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { context.Aiplanes.Add(model); await context.SaveChangesAsync(); return(Ok(model)); } catch (System.Exception ex) { return(BadRequest(new { message = $"Nao foi possivel adicionar o plano de voo MSG: {ex.Message}" })); } }
private async Task HandleAirplaneLanded(Airplane airplane, IDictionary <string, AirplaneState> future) { // Just remove the airplane form the flying airplanes set string callSign = airplane.FlightPlan.CallSign; await TableStorageOperationAsync( () => flyingAirplanesTable_.DeleteFlyingAirplaneCallSignAsync(callSign, shutdownTokenSource_.Token), null, nameof(FlyingAirplanesTable.DeleteFlyingAirplaneCallSignAsync)); // Update the projected airplane state to "Unknown Location" to ensure we do not attempt to send any notifications about it. future[callSign] = null; Assumes.NotNull(worldState_); airplane.FlightPlan.AddUniverseInfo(); logger_.LogInformation(LoggingEvents.FlightLanded, null, "{CallSign} completed flight from {DeparturePoint} to {Destination} in {Duration} time intervals", callSign, airplane.FlightPlan.DeparturePoint.Name, airplane.FlightPlan.Destination.Name, worldState_.CurrentTime - airplane.DepartureTime); }
public void Execute(Airplane airplane, GameObject target) { var targetDir = target.transform.position - airplane.transform.position; var rotation = Quaternion.LookRotation(targetDir); airplane.Rb.transform.rotation = Quaternion.Slerp(airplane.Rb.transform.rotation, rotation, Time.deltaTime * speedOfRotation); Vector3 forward = airplane.transform.forward; float angle = Vector3.SignedAngle(targetDir, forward, Vector3.up); var distanceBetween = Vector3.Magnitude(targetDir); if (distanceBetween < maxDistanceToShoot) { if (angle > -minAngelToShoot && angle < minAngelToShoot) { airplane.Shoot(); } } }
public void BookSlot(Slot slot, Airplane plane) { if (slot == null) { throw new ArgumentNullException(); } if (plane == null) { throw new ArgumentNullException(); } // TODO: Change to accommodate smaller planes in larger slots slot.IsAvailable = plane switch { Jumbo jumbo => false, Jet jet => false, Prop prop => false, _ => throw new UnknownPlaneException("Plane type not recognised") }; } }
public static List <Airline> GetAll() { SqlConnection conn = new SqlConnection(Program.connectionString); List <Airline> airlines = new List <Airline>(); try { conn.Open(); string query = "select id, name, airplane, departureAirport, destinationAirport from Airlines"; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { int id = (int)rdr["id"]; string imeLeta = (string)rdr["name"]; int avion = (int)rdr["airplane"]; Airplane airplane = AirplaneDAO.GetAvionById(avion); int id_aerodrom_poletanje = (int)rdr["departureAirport"]; int id_aerodrom_sletanje = (int)rdr["destinationAirport"]; Airport aerodrom_poletanje = AirportDAO.GetAerodromById(id_aerodrom_poletanje); Airport aerodrom_sletanje = AirportDAO.GetAerodromById(id_aerodrom_sletanje); Airline airline = new Airline(id, imeLeta, airplane, aerodrom_poletanje, aerodrom_sletanje); airlines.Add(airline); } rdr.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { conn.Close(); } return(airlines); }
public EditAirplaneWindow(Airplane airplane, Option option = Option.ADDING) { InitializeComponent(); this.airplane = airplane; this.option = option; this.DataContext = airplane; view = CollectionViewSource.GetDefaultView(Data.Instance.SeatsBusiness(airplane.RowNum, airplane.ColumnNum, airplane.Input)); DGBSeats.ItemsSource = view; view = CollectionViewSource.GetDefaultView(Data.Instance.SeatsEconomy(airplane.RowNum, airplane.ColumnNum, airplane.Input)); DGBSeats.IsReadOnly = true; DGESeats.ItemsSource = view; DGESeats.IsReadOnly = true; DGBSeats.IsSynchronizedWithCurrentItem = true; DGESeats.IsSynchronizedWithCurrentItem = true; DGBSeats.ColumnWidth = new DataGridLength(1, DataGridLengthUnitType.Star); DGESeats.ColumnWidth = new DataGridLength(1, DataGridLengthUnitType.Star); foreach (Aircompany a in Data.Instance.Aircompanies) { if (a.Active.Equals(false)) { NameA.Add(a); } } CbCompanyName.ItemsSource = NameA.Select(a => a); if (option.Equals(Option.EDIT)) { TxtPilot.IsEnabled = false; txtInput.IsEnabled = false; txtRowNumber.IsEnabled = false; txtColumnNumber.IsEnabled = false; } }
public Camera(Game game, Airplane playerAirplane) : base(game, playerAirplane.UpdateOrder + 1) { _playerAirplane = playerAirplane; }
// Use this for initialization void Start() { airplane = new Airplane(); airplane.targetX = airplaneStartX; airplane.targetY = airplaneStartY; timeToAct = turnLength; for (int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++) { allCubes[x,y] = (GameObject) Instantiate(cubePrefab, new Vector3(x*2 - 14, y*2 - 8, 10), Quaternion.identity); allCubes[x,y].GetComponent<CubeBehavior>().x = x; allCubes[x,y].GetComponent<CubeBehavior>().y = y; } } airplane.x = airplaneStartX; airplane.y = airplaneStartY; allCubes[airplaneStartX, airplaneStartY].GetComponent<Renderer>().material.color = Color.red; allCubes[depotX,depotY].GetComponent<Renderer>().material.color = Color.black; }
// Use this for initialization void Start() { myAirplane = new Airplane (); myBoat = new Boat (); myTrain = new Train (); allCubes = new GameObject[xNumber,yNumber]; // creates 16 cubes for (int xcount = 0; xcount < xNumber; xcount++) { for (int ycount = 0; ycount < yNumber; ycount++) { allCubes[xcount,ycount] = (GameObject) Instantiate(cubePrefab, new Vector3((xcount*2) - 16,(ycount*2) - 10, 0), Quaternion.identity); allCubes[xcount,ycount].GetComponent<CubeBehavior>().x = xcount; allCubes[xcount,ycount].GetComponent<CubeBehavior>().y = ycount; } } // set start location of airplane myAirplane.x = 0; myAirplane.y = 8; allCubes [0, 8].GetComponent<Renderer> ().material.color = Color.red; //set start location of train myTrain.x = 0; myTrain.y = 0; allCubes [0, 0].GetComponent<Renderer> ().material.color = Color.green; //set start location of boat myBoat.x = 15; myBoat.y = 8; allCubes [15, 8].GetComponent<Renderer> ().material.color = Color.blue; //make bottom corner depot and turn black (Need to keep it from turning white after airplane is there) allCubes [15, 0].GetComponent<Renderer> ().material.color = Color.black; myAirplane.timeToAct = myAirplane.turn; myTrain.timeToAct = myTrain.turn; myBoat.timeToAct = myBoat.turn; }
//when player clicks on plane, make the color change/have airplane glow to show it's activated //if player clicks active plane it deactivates (changes back to red/stop glowing) //if there is no active airplane, don't do anything, no teleportation, nothing // Use this for initialization void Start() { timeToDoTheThing = turnTime; allCubes = new GameObject[gridWidth,gridHeight]; for(int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++){ allCubes[x,y] = (GameObject) Instantiate (Cube, new Vector3 (x*2, y*2, 0), Quaternion.identity); allCubes[x,y].GetComponent<CubeBehavior>().x = x; allCubes[x,y].GetComponent<CubeBehavior>().y = y; } //reaching into CubeBehavior script, which is tracking the plane position //uses those coordinates in cubes spawned here (in allCubes) } allCubes [depotX,depotY].GetComponent<Renderer>().material.color = Color.black; airplane = new Airplane (); airplane.x = airplaneStartX; airplane.y = airplaneStartY; if(airplane.x == airplaneStartX && airplane.y == airplaneStartY){ allCubes[airplane.x,airplane.y].GetComponent<Renderer>().material.color = Color.red; allCubes [depotX,depotY].GetComponent<Renderer> ().material.color = Color.black; } print ("load airplane"); }
static void Main(string[] args) { Vehicle v = new Vehicle(); v.ModelName = "My Vehicle"; v.MaxSpeed = 180; v.Accelerate(); v.PrintInfo(); v.Brake(); v.PrintInfo(); StreetVehicle sv1= new StreetVehicle(2); sv1.PrintInfo(); //sv1.currentSpeed = 0;//Errore, campo non accessibile Car car = new Car(); car.Accendi(); car.Accelerate(); car.PrintInfo(); Vehicle sv2 = new StreetVehicle(4); //name hiding Airplane airplane = new Airplane(); airplane.TakeOff(); FlyingVehicle vair = airplane; vair.TakeOff(); //virtual override Car ferrari = new Car(); ferrari.Accelerate(); Vehicle vf = ferrari; vf.Accelerate(); //abstract class FlyingVehicle fv = new Helicopter(); //interface ICruiseControl Supercar scar = new Supercar(); scar.SetCruise(90); scar.StartControl(); ICruiseControl sedan = new Sedan(); (sedan as ICruiseControl).SetCruise(90); MyClass mc = new MyClass(); //mc.Bar(); errore, interfaccia esplicita (mc as IFoo).Bar(); //reimplementation Report report = new Report(); report.Print(); SubReport subReport = new SubReport(); subReport.Print(); IDocument irep = report; irep.Print(); IDocument isub = subReport; isub.Print(); irep.Print2(); isub.Print2(); irep.ExPrint(); isub.ExPrint(); irep.ExPrint2(); SpecialSubReport ssub = new SpecialSubReport(); IDocument issub = ssub; issub.ExPrint2(); //IComparable objects sorting ArrayList list = new ArrayList(); list.Add(new ComparableCar() { Targa = "DE234QW" }); list.Add(new ComparableCar() { Targa = "CP787MC" }); list.Add(new ComparableCar() { Targa = "BM41329" }); list.Sort(); //Abstract classes and interface MyDoc doc = new MyDoc(); doc.Print(); doc.Save(); }
// Use this for initialization void Start() { timeToAct += turnLength; //spawn a 16 by 9 grid of cubes //assign them to an array allCubes = new GameObject[gridWidth, gridHeight]; for (int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++) { allCubes[x,y] = (GameObject) Instantiate(cubePrefab, new Vector3(x*2 - 14, y*2 - 8, 10), Quaternion.identity); allCubes[x,y].GetComponent<CubeBehavior>().x = x; allCubes[x,y].GetComponent<CubeBehavior>().y = y; } } //make the first cube a red airplane airplane = new Airplane(); airplane.x = startX; airplane.y = startY; allCubes[startX,startY].GetComponent<Renderer>().material.color = Color.red; airplane.targetX = startX; airplane.targetY = startY; //there's a black cube in the bottom left allCubes[depotX,depotY].GetComponent<Renderer>().material.color = Color.black; }
// Use this for initialization void Start() { myAirplane = new Airplane (0, 90); myAirplane.locationX = 0; myAirplane.locationY = 16; cubes = new Transform[numCubesHor, numCubesVert]; // create a grid of cubes for (int x = 0; x < numCubesHor; x++) { for (int y = 0; y < numCubesVert; y++) { cubes [x, y] = (Transform)Instantiate (WhiteCube, new Vector3 (x * 2, y * 2, z), Quaternion.identity); cubes[x, y].GetComponent<CubeControl>().x = x; cubes[x, y].GetComponent<CubeControl>().y = y; cubes [x, y].renderer.material.color = Color.white; } } // Set the lower left to red cubes [0, 8].renderer.material.color = Color.red; cubes [15, 0].renderer.material.color = Color.black; }
// Use this for initialization void Start() { timeToAct += spawnFrequency; //this is making the airplane and setting the limits airplane = new Airplane (); airplane.cargo = 0; airplane.points = 0; airplane.x = 0; airplane.z = numCubes - 1; allCubes = new GameObject[numbCubes, numCubes]; //we're creating a 2D array as the grid for (int x = 0; x < numbCubes; x++) { for (int z = 0; z < numCubes; z++) { allCubes [x,z] = (GameObject)Instantiate (cubePrefab, new Vector3 (x * 2 -14, z * 2 - 14, 10), Quaternion.identity); allCubes [x,z].GetComponent<CubeBehavior>().x = x; allCubes [x,z].GetComponent<CubeBehavior>().z = z; allCubes [x,z].GetComponent<CubeBehavior>().GameController = this; } } allCubes[0,numCubes -1].GetComponent<Renderer>().material.color = Color.red; allCubes[numbCubes - 1, 0].GetComponent<Renderer> ().material.color = Color.black; }
public void Cleanup() { airplane = null; }
public void Init() { airplane = new Airplane(tailNumber, flightDistance); }
/* * Spawn airplane at location * * Called by flight controller */ public void SpawnAirplane(Vector2 location, Airplane _airplane, Transform parentObject) { // instantiate and set to position GameObject new_go = (GameObject) Instantiate (_airplane.gameObject); new_go.transform.position = new Vector3(location.x, new_go.transform.position.y, location.y); new_go.transform.parent = parentObject; // get component and link airplane = new_go.gameObject.GetComponent<Airplane>(); airplane.SetFlight(this); new_go.SetActive(true); state = STATE_SPAWNED; // obviously shouldn't do this because it will need to fly first, but for now it's ok state = STATE_ON_RUNWAY; }
//rules need to be set before game start // Use this for initialization void Start() { timeToAct = turnLength; allCubes = new GameObject[gridWidth, gridHeight]; for (int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++) { allCubes [x, y] = (GameObject)Instantiate (aCube, new Vector3 (x * 2 - 14, y * 2 - 8, 10), Quaternion.identity); allCubes [x, y].GetComponent<CubeBehaviour> ().x = x; allCubes [x, y].GetComponent<CubeBehaviour> ().y = y; } } foreach (GameObject oneCube in allCubes) { oneCube.GetComponent<Renderer> ().material.color = Color.white; } airplane = new Airplane (); airplane.targetX = airplaneStartX; airplane.targetY = airplaneStartY; airplane.x = airplaneStartX; airplane.y = airplaneStartY; allCubes [airplaneStartX, airplaneStartY].GetComponent<Renderer> ().material.color = Color.red; if (airplane.x == airplaneStartX && airplane.y == airplaneStartY) { airplane.cargo = Mathf.Min (airplane.cargo + 10, airplane.capacity); } allCubes [depotX, depotY].GetComponent<Renderer> ().material.color = Color.black; }
/** * @param NewID * @param NewSourceTown * @param NewDestinationTown * @param CurrentAirplane */ protected void Flight(char[] NewID, string NewSourceTown, string NewDestinationTown, Airplane CurrentAirplane) { // TODO implement here }