12. 03. 2024 ut 0. OOP Cell model - encapsulation, cell - attributes and methods, objects vs. instancies, inheritance, polymorphism How to conceptualize model and code 0.2 Private, protected and public Create class, that inderit to derivated class a try access to method depending on their privacy 1. OOP Lets have an Animals. All Animals have NameOfSpecies, Name of Individual and can produce Voice. All Species are Animals.(All Species are inherit from Animal.) 1.1 Define and create a class Animal - attributes - voice() method prints string "I am prototype of all Animals - I have no voice" 1.1.1 Create an instancies (as variable) of Animal and call method voice() 1.2 Define and create classes of Species that inherit from Animal: - a Dog that can bark - (implement now) produces sound "Haf, Haf" - a Cat that can meows - (do not implement now) produces sound "Mnau" - a Cow that can moo - (implement now) produces sound "Buuu" 1.3 Create an instancies (as variable) of Dogs, Cats nad Cow: 2 dogs, 3 cats and 1 cow. 1.3.1 Call on the instancies method voice() directly on the objects. 1.4.4 Set created instancies (of 2 dogs, 3 cats and 1 cow) to an array/s. (We have static count of animals, but it should not be usefull, and we dont know how many of dogs ... we should have. Solution? List of instancies? What type of the array is?) 1.3.4.1 Set one array of the Dogs and during iteration of array call method voice() on the each instance/dog. 1.3.4.2 Set one array of the Cats and during iteration of array call method voice() on each instance. 1.3.6 Set all instancies of the Animal to the one array. 1.3.7 Iterate array of all animals and call voice() method on them. (What type of an array? What function is called?) 1.4 Overload the methods of the objects so that when the voice function is called, each animal will write ("I am {name of animal} and {the sound the animal makes}") 1.6. Registr a count of all instancies of the species (How? Eg. by incrementator of class (static atrib)) 1.6.1 Set uID of all instancies (next id) - static atrib - method - class - more (constructor, ...) class Animal { string name; int id = 0; static int next_id; public Animal(string name) { this.name = name; this.id = next_id++; } }