Answered step by step
Verified Expert Solution
Link Copied!

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 # 3 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 >=1 Here are examples of first lines of animal data records: Bob Mammal Bear 300 Lucy Reptile Lizard 2 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 >=1 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: 1. 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 IS-A 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. 2. Based on the information from the step 1, write the class definition and methods. 3. You can design a simple main function for object creation and method calls. Object creation and method calling: You need to create four objects: m1, m2, r1 and r2. m1 object is a Mammal object with name = Bob, animal type = Mammal, species = Bear, mass =300 and litter =2 m2 object is a Mammal object with name = Doug, animal type = Mammal, species = Dog, mass =20 and litter =3 r1 object is a Reptile object with name = Carl, animal type = Reptile, species = Cottonmouth, mass =3, venomous = venomous r2 object is a Reptile object with name = Lucy, animal type = Reptile, species = Lizard, mass =2, 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 m1 using o display the animal type of m2 o display the name of m1 o display the mass of m2 o get the venomous information for r1 o get the name of r2 o get the type of animal for r1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

More Books

Students also viewed these Databases questions

Question

Explain the four methods for calculating the breakeven point.

Answered: 1 week ago