Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HA # 3 Topics: class, object, instantiation, methods, inheritance Problem Statement: Zoo In this assignment, you are going to model and implement a Zoo class.
HA # Topics: class, object, instantiation, methods, inheritance Problem Statement: Zoo In this assignment, you are going to model and implement a Zoo class. This will be an objectoriented program that processes few zoo animal data and displays information about the zoo animals. This assignment exercises the concept of container class, object, inheritance and code reusability using super Each animal in the zoo has the following information Name AnimalType Species Mass Explanation: o Name: The animals individual name. Contains no white space. o AnimalType: The type of animal. One of: Mammal or Reptile o Species: The animals species. Contains no white spaces o Mass: The animals mass weight in pounds. A whole number Here are examples of first lines of animal data records: Bob Mammal Bear Lucy Reptile Lizard The additional data depends on the AnimalType: Mammals: o Mammals has an additional information: LitterSize o Explanation: LitterSize is the average number of offspring the mammal has. A whole number Reptiles: o Additional information for Reptiles is: Venomous o Explanation: Venomous: Indicates whether the reptile has a venomous bite. One of: Venomous, Nonvenomous Program Design: Before starting of the program draw a general outline of your code. Think about it from the operational perspective: a A container class: Zoo which will hold all animal objects. Hint: a Calendar class holds all data objects. b Base class: What should be the base class? Hint: Think about an Animal class. i What are the methods and attributes that are common among all the animals? ii Hint: name, animal type, species and mass are the common instance variables. c What should be your sub classes? Can you identify the ISA relationships? Hint: Different species of animals Mammal and Reptiles. i What are the methods and attributes needed to properly define a subclass? Hint: mammals have litter size. ii How to use the init of the superclass and initialize additional attribute. Based on the information from the step write the class definition and methods. You can design a simple main function for object creation and method calls. Object creation and method calling: You need to create four objects: m m r and r m object is a Mammal object with name Bob, animal type Mammal, species Bear, mass and litter m object is a Mammal object with name Doug, animal type Mammal, species Dog, mass and litter r object is a Reptile object with name Carl, animal type Reptile, species Cottonmouth, mass venomous venomous r object is a Reptile object with name Lucy, animal type Reptile, species Lizard, mass venomous nonvenomous Create a Zoo object and add these objects to the zoo animals list after creating objects display the following information using the appropriate methods: o display method from Zoo class so that it prints all the animals in the zoo o display the species of m using o display the animal type of m o display the name of m o display the mass of m o get the venomous information for r o get the name of r o get the type of animal for r
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started