Esempio n. 1
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit rabbit = rabbits.FirstOrDefault(el => el.Name == name);
            int    index  = rabbits.IndexOf(rabbit);

            rabbits[index].Available = false;

            return(rabbits[index]);
        }
Esempio n. 2
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit rabbit = this.data.FirstOrDefault(x => x.Name == name);

            if (rabbit != null)
            {
                rabbit.Available = false;
            }
            return(rabbit);
        }
Esempio n. 3
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit toSell = data.FirstOrDefault(x => x.Name == name);

            int toSellIndex = data.IndexOf(toSell);

            data[toSellIndex].Available = false;

            return(toSell);
        }
Esempio n. 4
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit sellingRabbit = data.FirstOrDefault(r => r.Name == name);

            if (sellingRabbit != null)
            {
                sellingRabbit.Available = false;
            }
            return(sellingRabbit);
        }
Esempio n. 5
0
        public bool RemoveRabbit(string name)
        {
            if (data.Exists(x => x.Name == name))
            {
                Rabbit unwanted = data.FirstOrDefault(x => x.Name == name);
                data.Remove(unwanted);
                return(true);
            }

            return(false);
        }
Esempio n. 6
0
        public bool RemoveRabbit(string name)
        {
            Rabbit toRemove = data.FirstOrDefault(x => x.Name == name);

            if (toRemove == null)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
        public bool RemoveRabbit(string name)
        {
            Rabbit rabbit = repositoryOfRabbits.FirstOrDefault(x => x.Name == name);

            if (rabbit != null)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 8
0
        public void Add(Rabbit rabbit)
        {
            if (Rabbits.Count < Capacity)
            {
                Rabbits.Add(rabbit);

                data++;

                Count++;
            }
        }
Esempio n. 9
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit rabbitToSell = data.FirstOrDefault(
                x => x.Name == name);

            if (rabbitToSell != null)
            {
                rabbitToSell.Available = false;
            }
            return(rabbitToSell);
        }
Esempio n. 10
0
        public bool RemoveRabbit(string name)
        {
            Rabbit rabbit = this.data.FirstOrDefault(x => x.Name == name);

            if (rabbit != null)
            {
                this.data.Remove(rabbit);
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
 private void Button100Rabbits_Click(object sender, RoutedEventArgs e)
 {
     rabbit = new Rabbit[100];
     for (int i = 0; i < rabbit.Length; i++)
     {
         rabbit[i] = new Rabbit(("id " + (i + 1)), ("Rabbit " + (i)), 0);
     }
     for (int i = 0; i < rabbit.Length; i += 10)
     {
         ListBox100Rabbits.Items.Add(rabbit[i].info()); // add STRING NAME
     }
 }
Esempio n. 12
0
        public bool RemoveRabbit(string name)
        {
            Rabbit rabbit = this.rabbits.Where(r => r.Name == name).FirstOrDefault();

            if (rabbit != null)
            {
                this.rabbits.Remove(rabbit);
                return(true);
            }

            return(false);
        }
Esempio n. 13
0
        public bool RemoveRabbit(string name) //- removes a rabbit by given name, if such exists, and returns bool
        {
            Rabbit rabbit  = null;
            bool   isExist = rabbits.Any(x => x.Name == name);

            if (isExist)
            {
                rabbit = rabbits.FirstOrDefault(x => x.Name == name);
            }

            return(rabbits.Remove(rabbit));
        }
Esempio n. 14
0
        public static void Main()
        {
            ////Initialize the repository (Cage)
            //Cage cage = new Cage("Wildness", 20);
            ////Initialize entity
            //Rabbit rabbit = new Rabbit("Fluffy", "Blanc de Hotot");
            ////Print Rabbit
            //Console.WriteLine(rabbit); //Rabbit (Blanc de Hotot): Fluffy

            ////Add Rabbit
            //cage.Add(rabbit);
            //Console.WriteLine(cage.Count); //1
            //                               //Remove Rabbit
            //cage.RemoveRabbit("Rabbit Name"); //false

            //Rabbit secondRabbit = new Rabbit("Bunny", "Brazilian");
            //Rabbit thirdRabbit = new Rabbit("Jumpy", "Cashmere Lop");
            //Rabbit fourthRabbit = new Rabbit("Puffy", "Cashmere Lop");
            //Rabbit fifthRabbit = new Rabbit("Marlin", "Brazilian");

            ////Add Rabbits
            //cage.Add(secondRabbit);
            //cage.Add(thirdRabbit);
            //cage.Add(fourthRabbit);
            //cage.Add(fifthRabbit);

            ////Sell Rabbit by name
            //Console.WriteLine(cage.SellRabbit("Bunny")); //Rabbit (Brazilian): Bunny
            //                                             //Sell Rabbit by species
            //Rabbit[] soldSpecies = cage.SellRabbitsBySpecies("Cashmere Lop");
            //Console.WriteLine(string.Join(", ", soldSpecies.Select(f => f.Name))); //Jumpy, Puffy

            //Console.WriteLine(cage.Report());
            ////Rabbits available at Wildness:
            ////Rabbit (Blanc de Hotot): Fluffy
            ////Rabbit (Brazilian): Marlin
            ///


            //Add Rabbits
            Rabbit secondRabbit = new Rabbit("Bunny", "Brazilian");
            Rabbit thirdRabbit  = new Rabbit("Jumpy", "Cashmere Lop");
            Rabbit fourthRabbit = new Rabbit("Puffy", "Cashmere Lop");
            Rabbit fifthRabbit  = new Rabbit("Marlin", "Brazilian");
            Cage   cage         = new Cage("Wildness", 3);

            cage.Add(secondRabbit);
            cage.Add(thirdRabbit);
            cage.Add(fourthRabbit);
            cage.Add(fifthRabbit);
            Console.WriteLine(cage.Report());
        }
Esempio n. 15
0
 public bool RemoveRabbit(string name)
 {
     if (rabbits.Any(x => x.Name == name))
     {
         Rabbit rabbit = rabbits.FirstOrDefault(y => y.Name == name);
         rabbits.Remove(rabbit);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 16
0
        public static void Main()
        {
            Cage cage = new Cage("Wildness", 20);
            //Initialize entity
            Rabbit rabbit = new Rabbit("Fluffy", "Blanc de Hotot");

            //Print Rabbit
            Console.WriteLine(rabbit); //Rabbit (Blanc de Hotot): Fluffy

            //Add Rabbit
            cage.Add(rabbit);
            Console.WriteLine(cage.Count); //1
        }
Esempio n. 17
0
        public bool RemoveRabbit(string name)
        {
            Rabbit rabbitToRemove = data.FirstOrDefault(r => r.Name == name);

            if (rabbitToRemove == null)
            {
                return(false);
            }
            else
            {
                return(data.Remove(rabbitToRemove));
            }
        }
Esempio n. 18
0
        public Rabbit SellRabbit(string name)
        {
            //Rabbit soldRabbit = data.Where(r => r.Name == name).FirstOrDefault();

            Rabbit soldRabbit = data.FirstOrDefault(r => r.Name == name);

            if (soldRabbit != null)
            {
                soldRabbit.Available = false;
            }

            return(soldRabbit);
        }
Esempio n. 19
0
 public Rabbit SellRabbit(string name)
 {
     if (rabbits.Any(x => x.Name == name))
     {
         Rabbit rabbit = rabbits.FirstOrDefault(x => x.Name == name);
         rabbit.Available = false;
         return(rabbit);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 20
0
        public bool RemoveRabbit(string name)
        {
            Rabbit rabbit = data.FirstOrDefault(r => r.Name == name);

            if (rabbit == null)
            {
                return(false);
            }

            data.Remove(rabbit);

            return(true);
        }
Esempio n. 21
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit rabbit = this.data.FirstOrDefault(r => r.Name == name);

            for (int i = 0; i < this.Count; i++)
            {
                if (this.data[i].Name == name)
                {
                    this.data[i].Available = false;
                }
            }

            return(rabbit);
        }
Esempio n. 22
0
        public bool RemoveRabbit(string name)
        {
            bool isExist = false;

            Rabbit rabbit = this.data.FirstOrDefault(x => x.Name == name);

            if (rabbit != null)
            {
                this.data.Remove(rabbit);
                isExist = true;
            }

            return(isExist);
        }
Esempio n. 23
0
        public bool RemoveRabbit(string name)
        {
            Rabbit toRemove = data.FirstOrDefault(r => r.Name == name);

            if (toRemove != null)
            {
                if (data.Contains(toRemove))
                {
                    data.Remove(toRemove);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 24
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit targetRabbit = null;

            foreach (var rabbit in this.data)
            {
                if (rabbit.Name == name)
                {
                    targetRabbit     = rabbit;
                    rabbit.Available = false;
                }
            }
            return(targetRabbit);
        }
Esempio n. 25
0
        public Rabbit SellRabbit(string name)
        {
            var currRabbit = new Rabbit("", "");

            for (int i = 0; i < data.Count; i++)
            {
                if (data[i].Name == name)
                {
                    data[i].Available = false;
                    currRabbit        = data[i];
                }
            }
            return(currRabbit);
        }
Esempio n. 26
0
        public Rabbit SellRabbit(string name)
        {
            Rabbit currentRabbit = null;

            for (int i = 0; i < this.data.Count; i++)
            {
                if (this.data[i].Name == name)
                {
                    this.data[i].Available = false;
                    currentRabbit          = this.data[i];
                }
            }

            return(currentRabbit);
        }
        private void Button100Rabbits_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 100; i++)
            {
                var rabbit = new Rabbit();
                rabbit.RabbitName = "Rabbit" + i;
                rabbits.Add(rabbit); // add to list
            }

            // print rabbits
            foreach (var rabbit in rabbits)
            {
                ListBox100Rabbits.Items.Add(rabbit.RabbitName); // add STRING NAME
            }
        }
Esempio n. 28
0
        public Rabbit[] SellRabbitsBySpecies(string species)
        {
            Rabbit[] rabbits = new Rabbit[20];
            foreach (var item in Colection)
            {
                if (item.Value.Species == species)
                {
                    item.Value.Available = false;
                }
            }
            Colection.

            rabbits = Colection.Where(x => x.Value.Available == false).Select(x => x.Value).ToArray();
            return(rabbits);
        }
Esempio n. 29
0
        public Rabbit[] SellRabbitsBySpecies(string species)
        {
            var rabbitsBySpecies = new Rabbit[Capacity];
            var counter          = 0;

            for (int i = 0; i < data.Count; i++)
            {
                if (data[i].Species == species)
                {
                    data[i].Available         = false;
                    rabbitsBySpecies[counter] = data[i];
                    counter++;
                }
            }
            return(rabbitsBySpecies = rabbitsBySpecies.Where(c => c != null).ToArray());
        }
Esempio n. 30
0
        private void btn100Rabbits_Click(object sender, RoutedEventArgs e)
        {
            List <Rabbit> RabbitList = new List <Rabbit>();

            for (int i = 0; i < 100; i++)
            {
                var rab = new Rabbit();
                RabbitList.Add(rab);
            }

            foreach (var rabbit in RabbitList)
            {
                ListBox100Rabbits.Items.Add(rabbit);
            }

            // USE LIST VIEW
        }