public void AddCatHouse(CatHouse catHouse) { CatHouse[] temp = new CatHouse[++CatHouseCount]; if (Cathouses != null) { Cathouses.CopyTo(temp, 0); } temp[temp.Length - 1] = catHouse; Cathouses = temp; }
static void Main(string[] args) { Cat cat1 = new Cat { NickName = "Mestan", Age = 2, Gender = "D", Energy = 100, Price = 50, MealQuantity = 30 }; Cat cat2 = new Cat { NickName = "John", Age = 2, Gender = "E", Energy = 100, Price = 50, MealQuantity = 30 }; Cat[] cats = new Cat[2] { cat1, cat2 }; CatHouse catHouse1 = new CatHouse(); CatHouse catHouse2 = new CatHouse(); CatHouse[] catHouses = new CatHouse[2] { catHouse1, catHouse2 }; PetHouse petHouse = new PetHouse() { cats = cats, Cathouses = catHouses, CatHouseCount = 1 }; catHouse1.AddCat(ref cat1); catHouse1.AddCat(ref cat2); catHouse1.ShowCats(); petHouse.AddCatHouse(catHouse1); //catHouse1.RemoveByNickname("John"); //Console.Clear(); //catHouse1.ShowCats(); Console.WriteLine($"\n\n\nTotal meal quantity : {petHouse.CalculateMealQuantity()}"); Console.WriteLine($"\nTotal Price : {petHouse.CalculatePrice()}"); }