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

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

            if (ski != null)
            {
                Count--;
                return(data.Remove(ski));
            }
            return(false);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 16
0
        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
        }
Esempio n. 17
0
        public bool Remove(string manufacturer, string model)
        {
            Ski currentSki = skiCollection.FirstOrDefault(x => x.Manufacturer == manufacturer && x.Model == model);

            return(skiCollection.Remove(currentSki));
        }