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]); }
public Rabbit SellRabbit(string name) { Rabbit rabbit = this.data.FirstOrDefault(x => x.Name == name); if (rabbit != null) { rabbit.Available = false; } return(rabbit); }
public Rabbit SellRabbit(string name) { Rabbit toSell = data.FirstOrDefault(x => x.Name == name); int toSellIndex = data.IndexOf(toSell); data[toSellIndex].Available = false; return(toSell); }
public Rabbit SellRabbit(string name) { Rabbit sellingRabbit = data.FirstOrDefault(r => r.Name == name); if (sellingRabbit != null) { sellingRabbit.Available = false; } return(sellingRabbit); }
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); }
public bool RemoveRabbit(string name) { Rabbit toRemove = data.FirstOrDefault(x => x.Name == name); if (toRemove == null) { return(false); } return(true); }
public bool RemoveRabbit(string name) { Rabbit rabbit = repositoryOfRabbits.FirstOrDefault(x => x.Name == name); if (rabbit != null) { return(true); } return(false); }
public void Add(Rabbit rabbit) { if (Rabbits.Count < Capacity) { Rabbits.Add(rabbit); data++; Count++; } }
public Rabbit SellRabbit(string name) { Rabbit rabbitToSell = data.FirstOrDefault( x => x.Name == name); if (rabbitToSell != null) { rabbitToSell.Available = false; } return(rabbitToSell); }
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); }
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 } }
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); }
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)); }
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()); }
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); } }
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 }
public bool RemoveRabbit(string name) { Rabbit rabbitToRemove = data.FirstOrDefault(r => r.Name == name); if (rabbitToRemove == null) { return(false); } else { return(data.Remove(rabbitToRemove)); } }
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); }
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); } }
public bool RemoveRabbit(string name) { Rabbit rabbit = data.FirstOrDefault(r => r.Name == name); if (rabbit == null) { return(false); } data.Remove(rabbit); return(true); }
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); }
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); }
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); }
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); }
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); }
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 } }
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); }
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()); }
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 }