protected static LegDTO ToLegDTO(Leg leg) { VoyageNumber voyageNumber = leg.Voyage.VoyageNumber; UnLocode from = leg.LoadLocation.UnLocode; UnLocode to = leg.UnloadLocation.UnLocode; return new LegDTO(voyageNumber.IdString, from.IdString, to.IdString, leg.LoadTime, leg.UnloadTime); }
internal static LegDTO toLegDTO(Leg leg) { var voyageNumber = leg.Voyage.VoyageNumber; var from = leg.LoadLocation.UnLocode; var to = leg.UnloadLocation.UnLocode; return new LegDTO(voyageNumber.Value, from.Value, to.Value, leg.LoadTime, leg.UnloadTime); }
IEnumerator goToDirectionPair(Leg l1, Leg l2) { float movementTime = 0.5f; l1.goToIdle(movementTime); yield return new WaitForSeconds(movementTime); while(true) { l1.goToStart(movementTime); yield return new WaitForSeconds(movementTime); l2.goToIdle(movementTime); l1.goToEnd(movementTime); yield return new WaitForSeconds(movementTime); l2.goToStart(movementTime); yield return new WaitForSeconds(movementTime); l1.goToIdle(movementTime); l2.goToEnd(movementTime); yield return new WaitForSeconds(movementTime); if (waitForTransition) executeGaitTransition(); } }
public void AnErrorIsThrownIfAPlayerHasAVisitWhoIsNotInTheLeg() { var leg = new Leg(501); var player = new Player("Andy"); var visit = new Visit(player, 100); var newScore = leg.Visit(visit); }
public static Itinerary FetchRoutesForSpecification(RouteSpecification routeSpecification) { // TODO Remove hard-coding here var leg = new Leg(Location.Location.HongKong, Location.Location.Dallas, new DateTime(2012, 11, 9), new DateTime(2012, 11, 12)); var legs = new List<Leg> { leg }; return new Itinerary(legs); }
public void CountTotalGoalsPerLeg() { Leg leg = new Leg(); leg.AddMatch(new Match("avantul", "gloria", 1, 1)); leg.AddMatch(new Match("sageata", "concordia", 7, 1)); leg.AddMatch(new Match("astra", "ceahlaul", 3, 1)); Assert.AreEqual(14, leg.CountTotalGoals()); }
public void APlayerCanHaveAVisitAndSeeTheirScoreChange() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); var newScore = leg.Visit(visit); Assert.AreEqual(401, newScore); }
private static List<Leg> TwoLegsStub() { var leg1 = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 9), new DateTime(2012, 11, 12)); var leg2 = new Leg(Location.Location.LongBeach, Location.Location.Dallas, new DateTime(2012, 11, 13), new DateTime(2012, 11, 15)); return new List<Leg> { leg1, leg2 }; }
public void LegWithSamePropertiesShouldBeSame() { var leg = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 9), new DateTime(2012, 11, 12)); var expectedLeg = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 9), new DateTime(2012, 11, 12)); Assert.AreEqual(expectedLeg, leg); }
static void Main() { Programmist s = new Programmist(); Leg o1 = new Leg(); Leg o2 = new Leg(); Leg o3 = new Leg(); Leg people = new Leg(); s.Delete += o1.Show; // регистрация обработчика s.Delete += o1.Mix; // регистрация обработчика s.Delete += o1.Delete1; s.Delete += o1.Add; s.Mutate += o1.Show; s.CommandDelete(); s.CommandMutate(); Console.ReadLine(); //делегаты Func <int, int> retFunc = Factorial; int n1 = GetInt(6, retFunc); Console.WriteLine(n1); // 720 int n2 = GetInt(6, x => x * x); Console.WriteLine(n2); // 36 Console.Read(); Action <int, int> op; op = Add; Operation(10, 6, op); op = Substract; Operation(10, 6, op); Console.Read(); Programist acc = new Programist(); acc.Vvod += DisplayMessage; //добавление обработчика события acc.Delete += DisplayMessage; acc.Modify += DisplayMessage; acc.Replace += DisplayMessage; acc.Put(Console.ReadLine()); acc.Redact(acc.Slovo); acc.Redact1(acc.Slovo); acc.Replacer(acc.Slovo); Console.Read(); }
public ActionResult _AddLeg(int id) { Trip tr = db.findTrip(id); Leg lg = tr.LegsColl[tr.LegsColl.Count() - 1]; if (tr.complete) { return(PartialView("_TripComplete", lg)); // pass the last leg for completed trip } else { return(PartialView("_AddLeg", tr)); // } }
/// <summary> /// calculate distance from source to destenation using google maps /// </summary> /// <param name="source"></param> /// <param name="dest"></param> /// <returns></returns> /// public static int CalculateDistance(myEnum.TipeOfTravel tipeOfTravel, string source, string dest) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = tipeOfTravel == myEnum.TipeOfTravel.walking ? TravelMode.Walking : TravelMode.Driving, Origin = source, Destination = dest, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
public void BenenToevoegen(Leg been) { if (this.benen != null) { if (this.benen.GetLength(0) < maxBenen) { this.benen[this.benen.GetLength(0) + 1] = been; } else { this.benen[0] = been; } } }
public static int CalculateDistance(string source, string dest) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Driving, Origin = source, Destination = dest, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value / 1000); }
// // GET: /Leg/Edit/5 public ActionResult Edit(int id) { if (id != 0) { Leg leg = db.Legs.SingleOrDefault(a => a.LegId == id); if (leg == null) { return(HttpNotFound()); } ViewBag.TripId = new SelectList(db.Trips, "TripId", "Name", leg.TripId); return(View(leg)); } return(HttpNotFound()); }
public int CalculateDistance(string source, string dest) {//caculates the distance between the sorce to destuntion->by using google maps var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = source, Destination = dest, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
/// <summary> /// Initiate the %Grounding as an integrated solver by providing the root Transform, leg solvers, pelvis Transform and spine solver. /// </summary> public void Initiate(Transform root, Transform[] feet) { this.root = root; initiated = false; rootHit = new RaycastHit(); // Constructing Legs if (legs == null) { legs = new Leg[feet.Length]; } if (legs.Length != feet.Length) { legs = new Leg[feet.Length]; } for (int i = 0; i < feet.Length; i++) { if (legs[i] == null) { legs[i] = new Leg(); } } // Constructing pelvis if (pelvis == null) { pelvis = new Pelvis(); } string errorMessage = string.Empty; if (!IsValid(ref errorMessage)) { Warning.Log(errorMessage, root, false); return; } // Initiate solvers only if application is playing if (Application.isPlaying) { for (int i = 0; i < feet.Length; i++) { legs[i].Initiate(this, feet[i]); } pelvis.Initiate(this); initiated = true; } }
private Leg FromGoogleMaps(string source, string dest) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = source, Destination = dest, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg); }
public void Equals_01() { // arrange: DateTime loadTime = DateTime.UtcNow; DateTime unloadTime = DateTime.UtcNow + TimeSpan.FromDays(3); VoyageNumber voyageNumber = new VoyageNumber("VYGTEST"); IVoyage voyage = MockRepository.GenerateStrictMock <IVoyage>(); voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.Any(); UnLocode code1 = new UnLocode("CODAA"); ILocation loc1 = MockRepository.GenerateStrictMock <ILocation>(); loc1.Expect(l => l.UnLocode).Return(code1).Repeat.Any(); UnLocode code2 = new UnLocode("CODAB"); ILocation loc2 = MockRepository.GenerateStrictMock <ILocation>(); loc2.Expect(l => l.UnLocode).Return(code2).Repeat.Any(); voyage.Expect(v => v.WillStopOverAt(loc1)).Return(true).Repeat.AtLeastOnce(); voyage.Expect(v => v.WillStopOverAt(loc2)).Return(true).Repeat.AtLeastOnce(); // act: ILeg leg1 = new Leg(voyage, loc1, loadTime, loc2, unloadTime); ILeg leg2 = new Leg(voyage, loc1, loadTime, loc2, unloadTime); ILeg leg3 = MockRepository.GenerateStrictMock <ILeg>(); leg3.Expect(l => l.Voyage).Return(voyageNumber).Repeat.AtLeastOnce(); leg3.Expect(l => l.LoadLocation).Return(code1).Repeat.AtLeastOnce(); leg3.Expect(l => l.UnloadLocation).Return(code2).Repeat.AtLeastOnce(); leg3.Expect(l => l.LoadTime).Return(loadTime).Repeat.AtLeastOnce(); leg3.Expect(l => l.UnloadTime).Return(unloadTime).Repeat.AtLeastOnce(); // assert: Assert.AreEqual(leg1.GetHashCode(), leg2.GetHashCode()); Assert.IsTrue(leg1.Equals(leg2)); Assert.IsTrue(leg1.Equals(leg3)); Assert.IsTrue(leg2.Equals(leg1)); Assert.IsTrue(leg2.Equals(leg3)); Assert.IsTrue(leg1.Equals((object)leg2)); Assert.IsTrue(leg1.Equals((object)leg3)); Assert.IsTrue(leg2.Equals((object)leg1)); Assert.IsTrue(leg2.Equals((object)leg3)); voyage.VerifyAllExpectations(); loc1.VerifyAllExpectations(); loc2.VerifyAllExpectations(); leg3.VerifyAllExpectations(); }
/// <summary> /// calculate distance between 2 addresses /// </summary> /// <param name="loc"></param> /// <param name="dest"></param> /// <returns></returns> public int calculateDistance(Address loc, Address dest) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = loc.ToString(), Destination = dest.ToString() }; DirectionsResponse directions = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = directions.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
// GET: /Leg/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Leg ObjLeg = db.Legs.Find(id); if (ObjLeg == null) { return(HttpNotFound()); } return(View(ObjLeg)); }
/// <summary> /// function to calculate with google maps the distance between two adresses /// </summary> /// <param name="src"></param> /// <param name="dest"></param> /// <returns></returns> private int GoogleDistance(string src, string dest) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = src, Destination = dest, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
private Cargo shanghaiSeattleChicagoOnPacific2AndContinental3() { Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(L.SHANGHAI, L.CHICAGO, DateTime.Parse("2009-12-24"))); // A cargo with no itinerary is not misdirected Assert.IsFalse(cargo.IsMisdirected); Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific2, L.SHANGHAI, L.SEATTLE), Leg.DeriveLeg(V.continental3, L.SEATTLE, L.CHICAGO)); cargo.AssignToRoute(itinerary); return(cargo); }
/// <summary> /// the func to get the Distance between points /// </summary> /// <param name="PointA"></param> /// <param name="PointB"></param> /// <returns></returns> public static int CalculateDistance(string PointA, string PointB) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = PointA, Destination = PointB, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest);// לפעמים הפונקציה לא מצליחה לעבוד לא יודע למה ואז שמים ברייק פוינט וזה מסתדר לא יודע למה Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
public void testFindByCargoId() { TrackingId trackingId = new TrackingId("FGH"); Cargo cargo = cargoRepository.find(trackingId); Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin); Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination); IEnumerable <HandlingEvent> events = HandlingEventRepository.lookupHandlingHistoryOfCargo(cargo).distinctEventsByCompletionTime(); Assert.AreEqual(2, events.Count()); HandlingEvent firstEvent = events.ElementAt(0); assertHandlingEvent(cargo, firstEvent, HandlingActivityType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.None); HandlingEvent secondEvent = events.ElementAt(1); Voyage hongkongMelbourneTokyoAndBack = new Voyage.Builder(new VoyageNumber("0303"), SampleLocations.HONGKONG).addMovement(SampleLocations.MELBOURNE, new DateTime(1), new DateTime(2)).addMovement(SampleLocations.TOKYO, new DateTime(3), new DateTime(4)).addMovement(SampleLocations.HONGKONG, new DateTime(5), new DateTime(6)).build(); assertHandlingEvent(cargo, secondEvent, HandlingActivityType.LOAD, SampleLocations.HONGKONG, 150, 110, hongkongMelbourneTokyoAndBack); IEnumerable <Leg> legs = cargo.Itinerary.Legs; Assert.AreEqual(3, legs.Count()); Leg firstLeg = legs.ElementAt(0); assertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE); Leg secondLeg = legs.ElementAt(1); assertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM); Leg thirdLeg = legs.ElementAt(2); assertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI); }
/// <summary> /// calculate the distance between 2 address /// </summary> /// <param name="addressA">the address to calculate from</param> /// <param name="addressB">the address to calculate to</param> public int?Distance(string addressA, string addressB) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = addressA, Destination = addressB, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
public void AnErrorIsThronWhenAPlayerReaches0WithAnImpossibleCheckout() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); var checkoutVisit = new Visit(player, 101); leg.Visit(new Visit(player, 100));//401 leg.Visit(new Visit(player, 100));//301 leg.Visit(new Visit(player, 100));//201 leg.Visit(new Visit(player, 39));//162 leg.Visit(new Visit(player, 162)); }
// google maps public int caculateDistance(string mom, string nanny) { var drivingDirectionRequest = new DirectionsRequest() { TravelMode = TravelMode.Walking, Origin = mom, Destination = nanny, }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); return(leg.Distance.Value); }
public SingleTicket Reduce(AllUpTicket allUpTicket, Leg leg) { SingleTicket singleTicket = new SingleTicket { TicketId = allUpTicket.TicketId, BetId = allUpTicket.BetId, Odds = leg.Odds, UnitBets = allUpTicket.UnitBets, PoolId = leg.PoolId, LegNo = allUpTicket.LegsPlayed }; return(singleTicket); }
PickupRequest IPickupRequestRepository.GetForLeg(Leg leg) { _context.Entry(leg).Reference(l => l.AnsweredPickupRequest).Load(); AnsweredPickupRequest ans = leg.AnsweredPickupRequest; if (ans == null) { return(null); } _context.Entry(ans).Reference(a => a.Request).Load(); return(ans.Request); }
public static bool TryGet(MyGridProgram Prog, Leg LeftLeg, Leg RightLeg, out LegPair output) { output = null; if (LeftLeg == null || LeftLeg.Side != Base6Directions.Direction.Left) { return(false); } if (RightLeg == null || RightLeg.Side != Base6Directions.Direction.Right) { return(false); } output = new LegPair(LeftLeg, RightLeg); output.Program = Prog; return(true); }
//-------------------------------------------------------------------- // Build the Insert command String //-------------------------------------------------------------------- private String BuildInsertCommandLegs(Leg leg) { String command; StringBuilder sb = new StringBuilder(); // use a string builder to create the dynamic string string format = "yyyy-MM-dd HH:mm:ss"; sb.AppendFormat("Values('{0}',{1},'{2}',{3},'{4}','{5}','{6}','{7}','{8}','{9}')", leg.LegID, leg.LegNum.ToString(), leg.FlightID, leg.Flight_no.ToString(), leg.AirportFrom, leg.AirportTo, leg.Duration, leg.Departure.ToString(format), leg.Arrival.ToString(format), leg.AirlineID); String prefix = "INSERT INTO Leg_CS " + "(LegID,LegNum,FlightID,Flight_no,AirportFrom, AirportTo,Duration,Departure,Arrival,AirlineID) "; command = prefix + sb.ToString(); return(command); }
private LegPair(Leg L, Leg R) { Left = L; Right = R; Random rnd = new Random(); if (rnd.Next(0, 1) == 0) { Preferance = Base6Directions.Direction.Right; } else { Preferance = Base6Directions.Direction.Left; } }
public async Task <bool> UpdateLegAsync(int id) { Leg leg = await _context.Legs.FirstOrDefaultAsync(l => l.LegID == id); if (leg.LegCoordinates == null) { await CreateLegCoordinatesAsync(leg); } else { await UpdateLegCoordinatesAsync(leg); } return((await _context.SaveChangesAsync()) > 0); }
public void ItineraryWithDifferentSequenceOfLegsShouldNotBeEqual() { var leg1 = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 9), new DateTime(2012, 11, 12)); var leg2 = new Leg(Location.Location.LongBeach, Location.Location.Dallas, new DateTime(2012, 11, 13), new DateTime(2012, 11, 15)); var legs = new List<Leg> { leg1, leg2 }; var legsWithDifferentSequence = new List<Leg> { leg2, leg1 }; Assert.AreNotEqual(new Itinerary(legsWithDifferentSequence), new Itinerary(legs)); }
//calculae the time to walk the distance private static TimeSpan distanceTime(Address loc, Nanny nanny) { var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = loc.ToString(), Destination = nanny.personAddress.ToString() }; DirectionsResponse directions = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = directions.Routes.First(); Leg leg = route.Legs.First(); TimeSpan s = leg.ArrivalTime.Value - leg.DepartureTime.Value; return(s); }
public List <Item> BuildComponents() { var head = Head.Build(); var chassis = Chassis.Build(); var leg = Leg.Build(); var inventory = Inventory.Build(); return(new List <Item> { head, chassis, leg, inventory }); }
private void Read(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs) { if (rootBone == null) { rootBone = new VirtualBone(positions [0], rotations [0]); } else { rootBone.Read(positions [0], rotations [0]); } spine.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, 0, 1); leftArm.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, hasChest? 3: 2, 6); rightArm.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, hasChest? 3: 2, 10); if (hasLegs) { leftLeg.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, 1, 14); rightLeg.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, 1, 18); } for (int i = 0; i < rotations.Length; i++) { this.solvedPositions[i] = positions[i]; this.solvedRotations[i] = rotations[i]; } if (!initiated) { if (hasLegs) { legs = new Leg[2] { leftLeg, rightLeg } } ; arms = new Arm[2] { leftArm, rightArm }; if (hasLegs) { locomotion.Initiate(positions, rotations, hasToes); } raycastOriginPelvis = spine.pelvis.readPosition; spine.faceDirection = readRotations[0] * Vector3.forward; } }
public void FindByCargoId() { TrackingId trackingId = new TrackingId("FGH"); Cargo cargo = cargoRepository.Find(trackingId); Assert.AreEqual(SampleLocations.STOCKHOLM, cargo.Origin); Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin); Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination); Assert.IsNotNull(cargo.Delivery); IList <HandlingEvent> events = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId).DistinctEventsByCompletionTime(); Assert.AreEqual(2, events.Count); HandlingEvent firstEvent = events[0]; AssertHandlingEvent(cargo, firstEvent, HandlingType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.NONE); HandlingEvent secondEvent = events[1]; Voyage hongkongMelbourneTokyoAndBack = new Voyage.Builder( new VoyageNumber("0303"), SampleLocations.HONGKONG). AddMovement(SampleLocations.MELBOURNE, new DateTime(), new DateTime()). AddMovement(SampleLocations.TOKYO, new DateTime(), new DateTime()). AddMovement(SampleLocations.HONGKONG, new DateTime(), new DateTime()). Build(); AssertHandlingEvent(cargo, secondEvent, HandlingType.LOAD, SampleLocations.HONGKONG, 150, 110, hongkongMelbourneTokyoAndBack); IList <Leg> legs = cargo.Itinerary.Legs; Assert.AreEqual(3, legs.Count); Leg firstLeg = legs[0]; AssertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE); Leg secondLeg = legs[1]; AssertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM); Leg thirdLeg = legs[2]; AssertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI); }
public void APlayersScoreCanReachExacly0() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); var checkoutVisit = new Visit(player, 101); leg.Visit(visit);//401 leg.Visit(visit);//301 leg.Visit(visit);//201 leg.Visit(visit);//101 var score = leg.Visit(checkoutVisit);//1 = bust, therefore 101 Assert.AreEqual(0, leg.Players[0].Score); }
private void doGoogleMapsWork(object sender, DoWorkEventArgs e) { List <String> args = e.Argument as List <string>; var drivingDirectionRequest = new DirectionsRequest { TravelMode = TravelMode.Walking, Origin = args[0], Destination = args[1] }; DirectionsResponse drivingDirections = GoogleMaps.Directions.Query(drivingDirectionRequest); Route route = drivingDirections.Routes.First(); Leg leg = route.Legs.First(); e.Result = (leg.Distance.Value / 1000); Console.WriteLine(leg.Distance.Value); }
internal static Itinerary fromDTO(RouteCandidateDTO routeCandidateDTO, VoyageRepository voyageRepository, LocationRepository locationRepository) { var legs = new List <Leg>(routeCandidateDTO.getLegs().Count()); foreach (LegDTO legDTO in routeCandidateDTO.getLegs()) { var voyageNumber = new VoyageNumber(legDTO.getVoyageNumber()); var voyage = voyageRepository.find(voyageNumber); var from = locationRepository.find(new UnLocode(legDTO.getFrom())); var to = locationRepository.find(new UnLocode(legDTO.getTo())); legs.Add(Leg.DeriveLeg(voyage, from, to)); } return(new Itinerary(legs)); }
protected internal static Leg createLeg(Side side, Position position, double legOffset, short coxaId, short femurId, short tibiaId, double distanceToX, double distanceToZ, LegPosition legPosition) { Leg leg = new Leg(distanceToX, distanceToZ) { Side = side, Position = position, Offset = legOffset, X = legPosition.X, Y = legPosition.Y, Z = legPosition.Z, Coxa = new Coxa(3.8, legOffset, coxaId, 0, 0, side), Femur = new Femur(7.6, -90, femurId, 0, 0, side), Tibia = new Tibia(10.4, 120, tibiaId, 0, 0, side) }; return leg; }
public void LegsWithDifferentDatesShouldNotBeEqual() { var leg = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 9), new DateTime(2012, 11, 12)); var legWithDifferentLoadDate = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 10), new DateTime(2012, 11, 12)); var legWithDifferentUnloadDate = new Leg(Location.Location.HongKong, Location.Location.LongBeach, new DateTime(2012, 11, 9), new DateTime(2012, 11, 13)); Assert.AreNotEqual(legWithDifferentLoadDate, leg); Assert.AreNotEqual(legWithDifferentUnloadDate, leg); }
public Human(Gender g, string n) { entName = n; gender = g; increaseIDMain (); ID = IDMain; LeftArm = new Arm(MIDLEFT,g); //left and right arms with gender weighting RightArm = new Arm(MIDRIGHT,g); LeftLeg = new Leg (MIDMID, g); RightLeg = new Leg (MIDMID, g); Skeleton.Add (LeftArm); Skeleton.Add (LeftLeg); Skeleton.Add (RightArm); Skeleton.Add (RightLeg); }
public void APlayersScoreRemainsTheSameWhenTheirOverallScoreGoBelow2() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); leg.Visit(visit);//401 leg.Visit(visit);//301 leg.Visit(visit);//201 leg.Visit(visit);//101 var score = leg.Visit(visit);//1 = bust, therefore 101 Assert.AreEqual(101, leg.Players[0].Score); }
// float-float: currency swap, basis swap void InitLegs2(Leg leg1, Leg leg2, TradeInfo tinfo) { var sinfo = tinfo.Otc as SwapInfo; if (sinfo == null) return; leg1.NotionalCurrency = tinfo.Currency1; leg2.NotionalCurrency = tinfo.Currency2; leg1.StartDate = sinfo.SwapStartDate1; leg2.StartDate = sinfo.SwapStartDate2; leg1.EndDate = sinfo.SwapMaturity1; leg2.EndDate = sinfo.SwapMaturity2; leg1.Notional = Math.Abs(tinfo.Nominal1); leg2.Notional = Math.Abs(tinfo.Nominal2); leg1.Spread = sinfo.Spread1 / 100; leg2.Spread = sinfo.Spread2 / 100; // ... }
public void ICanPassInTheListOfPlayers() { var players = GetPlayerList(); var leg = new Leg(501, players); Assert.AreEqual(2, leg.Players.Count); }
public override void StartMovements() { ivr = this.GetComponent<InstantVR>(); characterTransform = ivr.transform; characterRigidbody = this.GetComponent<Rigidbody>(); headTarget = ivr.headTarget; leftHandTarget = ivr.leftHandTarget; rightHandTarget = ivr.rightHandTarget; hipTarget = ivr.hipTarget; leftFootTarget = ivr.leftFootTarget; rightFootTarget = ivr.rightFootTarget; animator = characterTransform.GetComponentInChildren<Animator>(); if (animator != null) { neck = animator.GetBoneTransform(HumanBodyBones.Neck); spine = animator.GetBoneTransform(HumanBodyBones.Spine); hips = animator.GetBoneTransform(HumanBodyBones.Hips); hipStartPosition = hips.position; fromNormNeck = Quaternion.Inverse(Quaternion.LookRotation(characterTransform.forward)) * neck.rotation; fromNormTorso = Quaternion.Inverse(Quaternion.LookRotation(neck.position - spine.position, hipTarget.forward)) * spine.rotation; fromNormHips = Quaternion.Inverse(Quaternion.LookRotation(hipTarget.forward)) * hips.rotation; leftArm = new ArmMovements_Free(ivr, ArmBasics.BodySide.Left, this); rightArm = new ArmMovements_Free(ivr, ArmBasics.BodySide.Right, this); leftLeg = new Leg(ArmBasics.BodySide.Left, animator, characterTransform); rightLeg = new Leg(ArmBasics.BodySide.Right, animator, characterTransform); } }
public void ICannotAddAPlayerToALegWithoutAName() { var leg = new Leg(501); var player = new Player(null); leg.AddPlayer(player); }
public void ICannotCreateALegWithAStartScoreLowerThan2() { var leg = new Leg(-1); }
public void ICannotAddAPlayerToALegWithANameAsEmptyString() { var leg = new Leg(501); var player = new Player(""); leg.AddPlayer(player); }
public void ICannotAddAPlayerToALegWithANameLongerThan10Characters() { var leg = new Leg(501); var player = new Player("12345678910"); leg.AddPlayer(player); }
public void ICannotAdd2PlayersToALegWithTheSameName() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); leg.AddPlayer(player); }
/// <summary> /// Prepares the legs on this path by allocating a unique ID to each primary face (and /// ensure that the primary face is cross-referenced to it's associated leg). /// </summary> /// <param name="opSequence">The sequence of the edit that created the legs.</param> /// <param name="legs">The legs involved (with only primary faces attached).</param> /// <returns>The last internal ID that was reserved.</returns> static uint PrepareLegs(uint opSequence, Leg[] legs) { // Allocate sequence numbers for each leg + primary face uint nextId = opSequence; foreach (Leg leg in legs) { // Reserve an ID for the leg itself (used for center point if the leg // is a circular arc). nextId++; // We should only be dealing with the primary face (alternate face comes via update, // or via deserialization of data that originated from the CEdit application). Debug.Assert(leg.AlternateFace == null); // Allocate a sequence number for the face LegFace face = leg.PrimaryFace; nextId++; face.Sequence = new InternalIdValue(nextId); // Reserve two IDs for every span (regardless of whether any feature will be created for it). nextId += ((uint)face.NumSpan * 2); // Ensure the face has been cross-referenced to the associated leg face.Leg = leg; } return nextId; }
public void AddNewMatch() { Leg leg = new Leg(); leg.AddMatch(new Match("avantul", "gloria", 1, 1)); Assert.AreEqual(1, leg.CountMatches()); }
public void ICanCheckIfTheLegHasBeenWonWhenPlayerHasWon() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); leg.Visit(new Visit(player, 100));//401 leg.Visit(new Visit(player, 100));//301 leg.Visit(new Visit(player, 100));//201 leg.Visit(new Visit(player, 100));//101 leg.Visit(new Visit(player, 101));//0 var hasWon = leg.HasPlayerWon(player); Assert.IsTrue(hasWon); }
public void ICanAddAPlayerToALeg() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); Assert.AreEqual(1, leg.Players.Count); Assert.AreEqual("Andy", leg.Players[0].Name); Assert.AreEqual(501, leg.Players[0].Score); }
// fixed-float: irswap void InitLegs(Leg payLeg, Leg recLeg, TradeInfo tinfo) { var sinfo = tinfo.Otc as SwapInfo; var floatLeg = payLeg.IsFixedRate ? recLeg : payLeg; var fixedLeg = payLeg.IsFixedRate ? payLeg : recLeg; if (sinfo == null) return; payLeg.NotionalCurrency = tinfo.Currency1; recLeg.NotionalCurrency = tinfo.Currency1; payLeg.StartDate = sinfo.SwapStartDate1; recLeg.StartDate = sinfo.SwapStartDate1; payLeg.EndDate = sinfo.SwapMaturity1; recLeg.EndDate = sinfo.SwapMaturity1; payLeg.Notional = Math.Abs(tinfo.Nominal1); recLeg.Notional = Math.Abs(tinfo.Nominal1); fixedLeg.FixedRate = tinfo.Price / 100; if (sinfo.Spread2 != 0) // L2 is floating leg floatLeg.Spread = sinfo.Spread2 / 100; if (sinfo.FirstFixingRate != 0) floatLeg.FirstFixing = sinfo.FirstFixingRate / 100; }
public void ICanCreateA501Leg() { var leg = new Leg(501); Assert.AreEqual(501, leg.StartScore); }