public IActionResult Create([FromBody] ThemePark themePark) { _context.ThemeParks.Add(themePark); _context.SaveChanges(); return(CreatedAtRoute("GetThemePark", new { id = themePark.ThemeParkId }, themePark)); }
private void InitVisitors(ThemePark themePark) { themePark.Visitors = Enumerable.Range(0, themePark.NumberOfVisitors).Select((i) => { var visitor = new Visitor(); visitor.Init(themePark.Attractions); return(visitor); }).ToList(); }
//CREATE public async Task <bool> CreateParkAsync(ParkCreate model) { ThemePark entity = new ThemePark { Name = model.Name, City = model.City, State = model.State }; _context.Parks.Add(entity); var changeCount = await _context.SaveChangesAsync(); return(changeCount == 1); }
public ThemeParkState(int numVisitors, int operationMinutes, double ticketPrice) { themePark = new ThemePark { NumberOfVisitors = numVisitors, OperationMinutes = operationMinutes, TicketPrice = ticketPrice, IncentivesBudget = ticketPrice * numVisitors / 10, IncentiveGenerationInterval = 1, ShouldGenerateIncentives = false }; InitVisitors(themePark); }
public Attraction GetNextAttraction(ThemePark themePark, IDictionary <Attraction, double> attractionPayoffMap, Point lastLocation) { IDictionary <Attraction, double> modifiedAttractionPayoffMap = new Dictionary <Attraction, double>(); double maxWaitTime = (double)attractionPayoffMap.Aggregate((l, r) => l.Key.EstimatedWaitTime > r.Key.EstimatedWaitTime ? l : r).Key.EstimatedWaitTime; foreach (var keyValuePair in attractionPayoffMap) { var waitTimeRelativeToMax = (double)keyValuePair.Key.EstimatedWaitTime / (double)maxWaitTime * 0.5; var modifiedPayoff = keyValuePair.Value * (1.0 - waitTimeRelativeToMax); modifiedAttractionPayoffMap.Add(keyValuePair.Key, modifiedPayoff); } return(modifiedAttractionPayoffMap.Aggregate((l, r) => l.Value > r.Value ? l : r).Key); }
public bool CreateThemePark(ThemeParkCreate model) { ThemePark themePark = new ThemePark() { ThemeParkName = model.ThemeParkName, ThemeParkCity = model.ThemeParkCity, ThemeParkState = model.ThemeParkState }; using (var ctx = new ApplicationDbContext()) { ctx.ThemeParks.Add(themePark); return(ctx.SaveChanges() == 1); } }
public Attraction GetNextAttraction(ThemePark themePark, IDictionary <Attraction, double> attractionPayoffMap, Point lastLocation) { IDictionary <Attraction, double> modifiedAttractionPayoffMap = new Dictionary <Attraction, double>(); double maxDistance = Math.Sqrt(Math.Pow(themePark.Dimensions.X - 1 - 0, 2) + Math.Pow(themePark.Dimensions.Y - 1 - 0, 2)); foreach (var keyValuePair in attractionPayoffMap) { var distance = Math.Sqrt(Math.Pow(lastLocation.X - keyValuePair.Key.Location.X, 2) + Math.Pow(lastLocation.Y - keyValuePair.Key.Location.Y, 2)); var distanceRelativeToMax = distance / maxDistance * 0.5; var modifiedPayoff = keyValuePair.Value * (1.0 - distanceRelativeToMax); modifiedAttractionPayoffMap.Add(keyValuePair.Key, modifiedPayoff); } return(modifiedAttractionPayoffMap.Aggregate((l, r) => l.Value > r.Value ? l : r).Key); }
public IActionResult Update(int id, [FromBody] ThemePark item) { var themePark = _context.ThemeParks.Find(id); if (themePark == null) { return(NotFound()); } themePark.ThemeParkName = item.ThemeParkName; themePark.Longitude = item.Longitude; themePark.Latitude = item.Latitude; _context.ThemeParks.Update(themePark); _context.SaveChanges(); return(NoContent()); }
static void Main(string[] args) { ThemePark warwarLand = new ThemePark(); warwarLand.TicketCost = 90; warwarLand.AverageDailyAttendance = 50000; warwarLand.ThemeParkName = "War War Land"; warwarLand.themeParkRides.Add(new ThemeParkRide("Haunted Mansion", 5)); warwarLand.themeParkRides.Add(new ThemeParkRide("Teacups", 7)); warwarLand.themeParkRides.Add(new ThemeParkRide("Pirates of the Caribean", 5)); warwarLand.PrintRides(); warwarLand.themeParkFood.Add(new ThemeParkRestaurant("Pizzasaurus Rex", 5, 3)); warwarLand.themeParkFood.Add(new ThemeParkRestaurant("Planet Mars Burgers", 8, 7.5F)); warwarLand.themeParkFood.Add(new ThemeParkRestaurant("Salads Undersea", 3, 6)); warwarLand.PrintRestaurants(); warwarLand.PrintProfit(); }
public Attraction GetNextAttraction(ThemePark themePark) { return(AttranctionSelectionStrategy.GetNextAttraction(themePark, this.AttractionPayoffMap, this.Location)); }
public Attraction GetNextAttraction(ThemePark themePark, IDictionary <Attraction, double> attractionPayoffMap, Point lastLocation) { return(attractionPayoffMap.Aggregate((l, r) => l.Value > r.Value ? l : r).Key); }