Exemple #1
0
 public void Add(Ski ski)
 {
     if (skiData.Count < Capacity)
     {
         skiData.Add(ski);
     }
 }
Exemple #2
0
 public void Add(Ski ski)
 {
     if (this.Capacity > this.Count)
     {
         skiCollection.Add(ski);
     }
 }
Exemple #3
0
 public void Add(Ski ski)
 {
     if (data.Count + 1 <= Capacity)
     {
         data.Add(ski);
     }
 }
Exemple #4
0
 public void Add(Ski ski)
 {
     if (Capacity > Count)
     {
         data.Add(ski);
     }
 }
Exemple #5
0
 public void Add(Ski ski)
 {
     if (skies.Count < Capacity)
     {
         skies.Add(ski);
     }
 }
Exemple #6
0
 public void Add(Ski ski)
 {
     if (Count < Capacity)
     {
         data.Add(ski);
         Count++;
     }
 }
Exemple #7
0
        public void Add(Ski ski)
        {
            if (this.Count == this.Capacity)
            {
                throw new InvalidOperationException();
            }

            this.ski.Add(ski);
        }
Exemple #8
0
 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);
 }
Exemple #9
0
        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);
        }
Exemple #10
0
        public bool Remove(string manufacturer, string model)
        {
            Ski ski = GetSki(manufacturer, model);

            if (ski != null)
            {
                Count--;
                return(data.Remove(ski));
            }
            return(false);
        }
Exemple #11
0
        public Ski GetNewestSki()
        {
            List <Ski> newestSkiList = skiData.OrderByDescending(s => s.Year).ToList();
            Ski        newestSki     = newestSkiList.FirstOrDefault();

            if (newestSki != null)
            {
                return(newestSki);
            }

            return(null);
        }
Exemple #12
0
        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);
        }
Exemple #13
0
        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);
        }
Exemple #14
0
        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);
            }
        }
Exemple #15
0
        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
        }
Exemple #17
0
        public bool Remove(string manufacturer, string model)
        {
            Ski currentSki = skiCollection.FirstOrDefault(x => x.Manufacturer == manufacturer && x.Model == model);

            return(skiCollection.Remove(currentSki));
        }