public void ChangeLeaperInfo(Leaper leaper, Event events, Host host) { leaper.CurrentEventID = events.ID; leaper.CurrentDateTime = events.DateTime; leaper.CurrentHostID = host.ID; }
public List <string> GetLeaps(Leaper leaperSelected) { var leapsToReturn = _leaps.Where(leap => leap.Leaper == leaperSelected) .Select(leap => $"Location: {leap.SingleEvent.Description}\nDate: {(leap.SingleEvent.DateTime).ToString("dddd, dd MMMM yyyy")}\nHost: {leap.Host.Name}") .ToList(); return(leapsToReturn); }
public static bool BudgetCheck(Leaper leaperToCheck, Event eventToCheck) { var leaperDate = leaperToCheck.CurrentDateTime; var eventDate = eventToCheck.DateTime; TimeSpan differenceBetweenDates = leaperDate - eventDate; // makes it a positive number incase it was a negative var travelCost = Math.Abs(differenceBetweenDates.Days) * 1000; Console.WriteLine($"Leaping from {leaperDate} to {eventDate}."); Console.WriteLine($"Cost of {Math.Abs(differenceBetweenDates.Days)} day leap: ${travelCost}."); if (travelCost <= _budget) { _budget -= travelCost; Console.WriteLine($"New Budget: {_budget}."); return(true); } else { do { Console.WriteLine($"Insufficient funds budgeted for selected leap. Please try again or request additional funds.\n" + $"1: Request additional funds.\n" + $"2: Attempt another leap."); var choice = Console.ReadLine(); switch (choice) { case "1": AddMoney(); break; case "2": Console.WriteLine("Returning to leaper selection."); return(false); default: Console.WriteLine("Invalid Input. Returning to leaper selection."); return(false); } } while (travelCost > _budget); _budget -= travelCost; Console.WriteLine($"New Budget: {_budget}."); return(true); } }
public void ChangeFinishedLeapInfo(Leaper leaper) { if (leaper.CurrentEventID == 100) { return; } // selects the leaper's finished event and sets 'isPutRight' to true var finishedLeap = _events.First(eventThing => eventThing.ID == leaper.CurrentEventID); finishedLeap.isPutRight = true; // selects the finished Host and sets it back to false (the Host is becoming available again because the leaper is leaving this host & event) finishedLeap.Hosts[leaper.CurrentHostID] = false; // selects a random event - if the event's date is in the future, then there is a 15% chance the future event isPutRight will be set to false var randomEvent = _events[RandomNumber(0, _events.Count())]; if (randomEvent.DateTime > leaper.CurrentDateTime && RandomNumber(1, 100) <= 15) { randomEvent.isPutRight = false; } }