public ActionResult <IEnumerable <string> > Get() { var strategy = _strategyFactory.GetStrategy("agora vai"); var uplload = _strategyFactory.GetStrategy(1d); var resultado = strategy.Executa("agora vai " + uplload.Executa(1d)); return(Ok(resultado)); }
public Ticket CreateTicket(int reservationId, string fName, string lName, DTO dto) { var res = _resRepo.Get(reservationId); if (res.TicketId != null) { throw new InvalidOperationException("ticket has been already issued to this reservation, unable to create another one"); } var placeInRun = _runRepository.GetPlaceInRun(res.PlaceInRunId); var newTicket = new Ticket() { ReservationId = res.Id, CreatedDate = DateTime.Now, FirstName = fName, LastName = lName, Status = TicketStatusEnum.Active, PriceComponents = new List <PriceComponent>() }; newTicket.PriceComponents = _strategyFactory.GetStrategy(_runRepository, _trainRepository, dto).CalculatePrice(placeInRun); _tickRepo.Create(newTicket); return(newTicket); }
/// <summary> /// Inizializza un gioco tra due strategie /// </summary> /// <param name="strategy1"></param> /// <param name="strategy2"></param> /// <param name="num">Il numero di giocatori della partita. Sono supportati solo 2 o 4 giocatori</param> public void InitializeRoboMatch(string strategy1, string strategy2, int num) { _ui.Send($"Briscola a {num} giocatori"); var strategyA1 = _strategyFactory.GetStrategy(strategy1); var strategyB1 = _strategyFactory.GetStrategy(strategy2); switch (num) { case 2: _ui.Send($"{strategy1} vs. {strategy2}"); _game.Join(strategy1, strategyA1); _game.Join(strategy2, strategyB1); break; case 4: var strategyA2 = _strategyFactory.GetStrategy(strategy1); var strategyB2 = _strategyFactory.GetStrategy(strategy2); var a1Name = $"{strategy1}-P1"; var a2Name = $"{strategy1}-P2"; var b1Name = $"{strategy2}-P1"; var b2Name = $"{strategy2}-P2"; _ui.Send($"Squadra {strategy1}: {a1Name} e {a2Name}"); _ui.Send($"Squadra {strategy2}: {b1Name} e {b2Name}"); _game.Join(a1Name, strategyA1); _game.Join(b1Name, strategyB1); _game.Join(a2Name, strategyA2); _game.Join(b2Name, strategyB2); break; default: throw new NotSupportedException("Only 2 or 4 player game is supported"); } _ui.Send("Buona Partita!\n"); }
public void InitializeRoboMatch(string strategy1, string strategy2, int num) { _ui.Send("Briscola a 4 giocatori"); var strategyA1 = _strategyFactory.GetStrategy(strategy1); var strategyA2 = _strategyFactory.GetStrategy(strategy1); var strategyB1 = _strategyFactory.GetStrategy(strategy2); var strategyB2 = _strategyFactory.GetStrategy(strategy2); var players = new[] { "Bill Gates", "Steve Jobbs", "Mark Zuckerberg", "Alberto Baruzzo", "Alan Turing", "Linus Torvalds", "Elliot Alderson" }; var toPlay = players.OrderBy(p => Guid.NewGuid()).Take(4).ToArray(); _ui.Send("Squadra PC: " + toPlay.ElementAt(0) + " e " + toPlay.ElementAt(2)); _ui.Send("Squadra Mac: " + toPlay.ElementAt(1) + " e " + toPlay.ElementAt(3)); _ui.Send("Buona Partita!\n"); _game.Join(toPlay.ElementAt(0), strategyA1); _game.Join(toPlay.ElementAt(1), strategyB1); _game.Join(toPlay.ElementAt(2), strategyA2); _game.Join(toPlay.ElementAt(3), strategyB2); }
public ActionResult ReservePlace(int placeId, DTO dto = null) { var place = _runRepo.GetPlaceInRun(placeId); var reservation = _resServ.Reserve(place); var model = new ReservationViewModel() { Reservation = reservation, PlaceInRun = place, PriceComponents = _strategyFactory.GetStrategy(_runRepo, _trainRepo, dto).CalculatePrice(place), Date = place.Run.Date, Train = _trainRepo.GetTrainDetails(place.Run.TrainId), }; return(View(model)); }