public void Add(Ski ski) { if (skiData.Count < Capacity) { skiData.Add(ski); } }
public void Add(Ski ski) { if (this.Capacity > this.Count) { skiCollection.Add(ski); } }
public void Add(Ski ski) { if (data.Count + 1 <= Capacity) { data.Add(ski); } }
public void Add(Ski ski) { if (Capacity > Count) { data.Add(ski); } }
public void Add(Ski ski) { if (skies.Count < Capacity) { skies.Add(ski); } }
public void Add(Ski ski) { if (Count < Capacity) { data.Add(ski); Count++; } }
public void Add(Ski ski) { if (this.Count == this.Capacity) { throw new InvalidOperationException(); } this.ski.Add(ski); }
public bool Remove(string manufacturer, string model) { if (data.Any(s => s.Manufacturer == manufacturer && s.Model == model)) { Ski skiToRemove = data.FirstOrDefault(s => s.Manufacturer == manufacturer && s.Model == model); data.Remove(skiToRemove); return(true); } return(false); }
public Ski GetSki(string manufacturer, string model) { Ski currentSki = skiData.FirstOrDefault(s => s.Manufacturer == manufacturer && s.Model == model); if (currentSki != null) { return(currentSki); } return(null); }
public bool Remove(string manufacturer, string model) { Ski ski = GetSki(manufacturer, model); if (ski != null) { Count--; return(data.Remove(ski)); } return(false); }
public Ski GetNewestSki() { List <Ski> newestSkiList = skiData.OrderByDescending(s => s.Year).ToList(); Ski newestSki = newestSkiList.FirstOrDefault(); if (newestSki != null) { return(newestSki); } return(null); }
public bool Remove(string manufacturer, string model) { Ski ski = skiData.FirstOrDefault(s => s.Model == model && s.Manufacturer == manufacturer); if (ski != null) { skiData.Remove(ski); return(true); } return(false); }
public bool Remove(string manufacturer, string model) { bool success = false; Ski skiToRemove = data.FirstOrDefault(s => s.Manufacturer == manufacturer && s.Model == model); if (skiToRemove != null) { success = data.Remove(skiToRemove); } return(success); }
public bool Remove(string manufacturer, string model) { Ski ski = data.FirstOrDefault(s => s.Manufacturer == manufacturer && s.Model == model); if (ski == null) { return(false); } else { data.Remove(ski); return(true); } }
public bool Remove(string manufacturer, string model) { Ski skiToRemove = skies.Find(x => x.Manufacturer == manufacturer && x.Model == model); if (skiToRemove == null) { return(false); } else { skies.Remove(skiToRemove); return(true); } }
static void Main(string[] args) { // Initialize the repository SkiRental skiRental = new SkiRental("New Alpine ski rental", 5); // Initialize entity Ski firstSkiSet = new Ski("Rossignol", "XC70", 2017); // Print Ski Console.WriteLine(firstSkiSet); // Rossignol - XC70 - 2017 // Add Ski skiRental.Add(firstSkiSet); // Remove Ski Console.WriteLine(skiRental.Remove("Rossignol", "XC90")); // False Console.WriteLine(skiRental.Remove("Rossignol", "XC70")); // True Ski secondSkiSet = new Ski("Fischer", "SpeedMax", 2018); Ski thirdSkiSet = new Ski("Salomon", "TopLine", 2020); skiRental.Add(secondSkiSet); skiRental.Add(thirdSkiSet); // Get Newest Ski Ski newestSki = skiRental.GetNewestSki(); Console.WriteLine(newestSki); // Salomon - TopLine - 2020 // Get Ski Ski salomonTopLine = skiRental.GetSki("Salomon", "TopLine"); Console.WriteLine(salomonTopLine); // Salomon - TopLine - 2020 // Count Console.WriteLine(skiRental.Count); // 2 // Get Statistics Console.WriteLine(skiRental.GetStatistics()); // The skis stored in New Alpine ski rental: // Fischer - SpeedMax – 2018 // Salomon - TopLine - 2020 }
public bool Remove(string manufacturer, string model) { Ski currentSki = skiCollection.FirstOrDefault(x => x.Manufacturer == manufacturer && x.Model == model); return(skiCollection.Remove(currentSki)); }