You are on page 1of 2
Lab exam (part 2) Consider the following UML diagram: Zoo | zainraraee> | ‘Animal = Getrones( vecto Batbires) vactorsAnimal> + Getammats(: vector-Animet>| + taaeind): Boo! S Gatfeinast) vector eone™ TSagnmat). boo! Garrotainimate nt operator r= (Anmat’y vod + petatosing name} boot com fave Sr eeu: ~SetSpec it Toe en Build all the files with the_classes described in the above diagram so that the following code: include include *Z00.h" include "Shark.h" include “Eagle.h" include *Lion.h" include “Tiger.h" include “Cow.h” int main() « Z00 23 2 += new Shark(); 2 += new Eagle(); 2 42 new Tiger(); 2 42 new Lion(); 2 4 new Cow()3 std::cout << “Total aninals in zoo: for (auto a : z.GetFishes()) std::cout << "Fish: " << a-sGetName() << std::endl; for (auto a : z.GetBirds()) std::cout << "Bird: " << a-sGetNane() << std::endl; for (auto a : z.GetMannals()) std::cout << "Mammal: " << a->GetName() << std::endl} << z.GetTotalAninals() << std::endl; for (auto a : z.GetFelines()) *'¢ a->GetName() << ", speed: " << a->GetSpeed() << std std::cout << "Feline: std::cout << "Zoo contains a tiger std::cout << "Zoo contains a monkey return 0; endl; boolalpha << z("Tiger") << std::endl]; boolalpha << 2("Nonkey") << std::endl; will out upon execution: Mann Observations: ‘¢ Animal class and all of its derived classes are inlined (there is no .cpp file, only a header file) ‘© Except for Zoo class, none of the rest of the classes have any data members ! Adding other data members and/or methods will impact G,2, G,6 and G,8 ‘© Itis recommended to use STL containers to solve this problem Grading: G41] Organize your project in 10 files: main.cpp, Animal.h, Feline.h, Lion.h, | 1p SB Tiger.h, Sharkch, Eagle.h, Cow:h, Zoa.h, and Zoo.cpp 6,2 | Organize the file Zoo.h to correspond to the UML diagram (one data 2p WE member, two operators, 5 getter methods). G3 _| Implementation of Zoo::GetTotalAnimals() 1p GA | Zoo::GetFishes(), Zoo::Getk correctly implemented method) Is() and Zoo::GetMammals() (3p each | 9p AB Correctly implement all virtual methods in classes Tiger, Lion, Eagle, Cow | 5p. and Shark. (1p for each) G,6_| Implementation of operator 1p 6,7 | implementation of operator function call (fo test if an animal exists in the | 3p (A 200) 6,8 | Implementation of Zoo::GetFelines() (requires using dynamic cast for 5p AB runtime checks) 6,9. | Program compiles and upon execution produces the expected results 3p xplanation: BB = the capability to correctly apply OOP principles (inheritance, polymorphism, etc) WB the capability to write C++ programs based on specifications The evaluation will consider all the relevant points for a criteria

You might also like