static void Main(string[] args) { PetStore <Dog> dogsStore = new PetStore <Dog>(); PetStore <Cat> catsStore = new PetStore <Cat>(); PetStore <Fish> fishStore = new PetStore <Fish>(); dogsStore.Insert(new Dog("Bobs", 3, true, "meat")); dogsStore.Insert(new Dog("Jacky", 5, false, "bread")); catsStore.Insert(new Cat("Jenny", 2, false, 6)); catsStore.Insert(new Cat("Jane", 4, true, 3)); fishStore.Insert(new Fish("Nemo", 1, "blue", 4)); fishStore.Insert(new Fish("Mui", 2, "green", 7)); dogsStore.BuyPet("Bobs"); catsStore.BuyPet("Mia"); Console.WriteLine("--------------------------------------------"); Console.WriteLine("These are the available pets in the stores:"); dogsStore.PrintPets(); catsStore.PrintPets(); fishStore.PrintPets(); }
static void Main(string[] args) { DogStore.Insert(new Dog() { Name = "Sparky", Age = 2, Type = "labrador", GoodBoi = true, FavoriteFood = "Chicken" }); DogStore.Insert(new Dog() { Name = "Sharko", Age = 12, Type = "dzukela", GoodBoi = false, FavoriteFood = "Papuchi" }); DogStore.PrintPets(); Console.WriteLine("Buying Trpe"); DogStore.BuyPet("Trpe"); Console.WriteLine("Buying Sparky"); DogStore.BuyPet("Sparky"); DogStore.PrintPets(); Console.WriteLine("------------------------------"); CatStore.Insert(new Cat() { Name = "Mitsi", Age = 2, Type = "domestic", Lazy = true, LivesLeft = 6 }); CatStore.Insert(new Cat() { Name = "Cleo", Age = 12, Type = "dzukela", Lazy = false, LivesLeft = 1 }); CatStore.PrintPets(); Console.WriteLine("Buying aaa"); CatStore.BuyPet("Aaa"); Console.WriteLine("Buying Cleo"); CatStore.BuyPet("Cleo"); CatStore.PrintPets(); Console.WriteLine("------------------------------"); FishStore.Insert(new Fish() { Name = "Fishy", Age = 2, Type = "clown fish", Color = "Orange", Size = "xs" }); FishStore.Insert(new Fish() { Name = "Bobby", Age = 12, Type = "shark", Color = "White", Size = "xxl" }); FishStore.PrintPets(); Console.WriteLine("Buying fishhhh"); FishStore.BuyPet("Fish"); Console.WriteLine("Buying Bobby"); FishStore.BuyPet("Bobby"); FishStore.PrintPets(); Console.ReadLine(); }
static void Main(string[] args) { dogStore.Insert(new Dog() { Name = "Sharko", Age = 8, Type = "Pinch", GoodBoi = false, FavoriteFood = "salad" }); dogStore.Insert(new Dog() { Name = "Sparky", Age = 2, Type = "Labrador", GoodBoi = true, FavoriteFood = "chicken" }); dogStore.PrintPets(); Console.WriteLine("Buying shaeko"); dogStore.BuyPet("Sharko"); Console.WriteLine("Buying shaeko"); dogStore.BuyPet("Sparky"); dogStore.PrintPets(); }
static void Main(string[] args) { PetStore <Dog> Dog1 = new PetStore <Dog>(); PetStore <Dog> Dog2 = new PetStore <Dog>(); PetStore <Cat> Cat1 = new PetStore <Cat>(); PetStore <Cat> Cat2 = new PetStore <Cat>(); PetStore <Fish> Fish1 = new PetStore <Fish>(); PetStore <Fish> Fish2 = new PetStore <Fish>(); Dog1.Insert(new Dog() { Name = "Dog1", Age = 5, FavouriteFood = "bacon", GoodBoi = true, Type = "Beagle" }); Dog2.Insert(new Dog() { Name = "Dog2", Age = 6, FavouriteFood = "meat", GoodBoi = true, Type = "Labrador" }); Cat1.Insert(new Cat() { Name = "Cat1", Age = 2, IsLazy = true, Type = "Some cat type", LivesLeft = 9 }); Cat2.Insert(new Cat() { Name = "Cat2", Age = 3, IsLazy = true, Type = "Some cat type3", LivesLeft = 8 }); Fish1.Insert(new Fish() { Name = "Fish1", Age = 1, Type = "Goldfish", Color = "gold", Size = 2 }); Fish2.Insert(new Fish() { Name = "Fish2", Age = 2, Type = "Goldfish2", Color = "gold", Size = 3 }); Dog1.PrintPets(); Dog2.PrintPets(); Cat1.PrintPets(); Cat2.PrintPets(); Fish1.PrintPets(); Fish2.PrintPets(); Dog1.BuyPet("Dog3"); Cat1.BuyPet("Cat1"); }
static void Main(string[] args) { #region Exercise // Create 4 classes: // Pet( abstract ) with Name, Type, Age and abstract PrintInfo() // Dog(from Pet) with GoodBoi and FavoriteFood // Cat(from Pet) with Lazy and LivesLeft // Fish(from Pet) with color, size // Create a PetStore generic class with : // Generic list of pets - Dogs, Cats or Fish depending on what is passed as T // Generic method printsPets() - Prints Dogs, Cats or Fish depending on what is passed as T // BuyPet() - Method that takes ‘name’ as parameter, find the first pet by that name, removes it from the list and gives a success message.If there is no pet by that name, inform the customer // Create a Dog, Cat and fish store with 2 pets each // Buy a dog and a cat from the Dog and Cat store // Call PrintPets() method on all stores #endregion PetStore <Dog> dogStore = new PetStore <Dog>(); PetStore <Cat> catStore = new PetStore <Cat>(); PetStore <Fish> fishStore = new PetStore <Fish>(); dogStore.Insert(new Dog() { Type = "dog", Name = "Nero", Age = 14, isGood = true, FavouriteFood = "chicken" }); dogStore.Insert(new Dog() { Type = "dog", Name = "Shegy", Age = 10, isGood = true, FavouriteFood = "beaf meat" }); dogStore.Insert(new Dog() { Type = "dog", Name = "Puppy", Age = 5, isGood = false, FavouriteFood = "eggs" }); dogStore.Insert(new Dog() { Type = "dog", Name = "Bully", Age = 7, isGood = true, FavouriteFood = "beaf meat" }); Console.WriteLine("---------All Dogs in Dog Store:---------"); dogStore.PrintPets(); dogStore.BuyPet("shegy "); catStore.Insert(new Cat() { Type = "cat", Name = "Mario", isLazy = true, LivesLeft = 10, Age = 2 }); catStore.Insert(new Cat() { Type = "cat", Name = "Luiji", isLazy = false, LivesLeft = 10, Age = 2 }); catStore.Insert(new Cat() { Type = "cat", Name = "Mimi", isLazy = false, LivesLeft = 9, Age = 3 }); Console.WriteLine("---------All Cats in Cat Store:---------"); catStore.PrintPets(); catStore.BuyPet("Mimi"); fishStore.Insert(new Fish() { Type = "fish", Name = "Boo", Color = "Blue", Size = 4.3f, Age = 4 }); fishStore.Insert(new Fish() { Type = "fish", Name = "Loly", Color = "Purple", Size = 3.5f, Age = 3 }); Console.WriteLine("---------All Fishes in Fish Store:---------"); fishStore.PrintPets(); fishStore.BuyPet("jiM "); }