public static void DoAction(FishStore s, Aquarium a) { Console.Clear(); var inventory = s.Inventory; for (int i = 0; i < inventory.Count; i++) { Console.WriteLine($"{i+1}. {inventory[i].Name}"); } Console.Write("> "); var chosenFish = Console.ReadKey(); Console.WriteLine(""); a.AddFish(inventory[int.Parse(chosenFish.KeyChar.ToString()) - 1]); }
public static void DoAction(FishStore s, Aquarium a) { Console.Clear(); var inventory = s.Inventory; for (int i = 0; i < inventory.Count; i++) { Console.WriteLine($"{i+1}. {inventory[i].Name}"); } Console.Write("> "); var chosenFish = Console.ReadKey(); Console.WriteLine(""); var keyPressed = chosenFish.KeyChar.ToString(); var integerValueOfKeyPressed = int.Parse(keyPressed); var fishInInventory = inventory[integerValueOfKeyPressed - 1]; a.AddFish(fishInInventory); }
private static void AddFishesAndSeaweeds() { //Aquarium.AddFish(new Tuna("Carlito", Sex.Male, 5)); Aquarium.AddFish(new Tuna("Lila", Sex.Female, 7)); Aquarium.AddFish(new Grouper("Cacao", Sex.Male, 8)); Aquarium.AddFish(new ClownFish("Homer", Sex.Male, 2)); //Aquarium.AddFish(new ClownFish("Bob", Sex.Male, 2)); //Aquarium.AddFish(new Sole("Kira", Sex.Female, 11)); Aquarium.AddFish(new Sole("Anna", Sex.Female, 3)); Aquarium.AddFish(new Bar("Nils", Sex.Male, 7)); Aquarium.AddFish(new Bar("Helene", Sex.Female, 4)); Aquarium.AddFish(new Carp("Balou", Sex.Male, 1)); Aquarium.AddFish(new Carp("Bagera", Sex.Male, 6)); Aquarium.AddSeaweed(new Seaweed()); Aquarium.AddSeaweed(new Seaweed()); Aquarium.AddSeaweed(new Seaweed()); Aquarium.AddSeaweed(new Seaweed()); }