I want to create a Zoo class, which keeps track of all the animals in the zoo using an Animal class. Would inheritance make sense here? Why, or why not? Explain your reasoning clearly.
What is Inheritance:
Since you want to make a class Zoo and for that class Inheritance make sense.
Using any programming language of your choice you can create a base class Animal and inherit other class like Dogs, Lions etc from the base class.
For example,
Step 1:
a) First step is to create a base class Animal.
b) In this class define some methods e.g. sleep, roam, eat etc. which are common to all the animals.
c) Define some properties which are common to all the animals e.g. food, hunger, picture etc.
d) Refer the diagram:
Step 2:
a) Create another class e.g. Lion, Cat, Dog, Hippo.
b) For this derived class, you can inherit the methods and properties defined in the base class.
c) Refer the diagram:
Step 3:
Using this inheritance concept you can create multiple classes and reuse the methods and properties defined in the base class.
Advantages of using inheritance:
I want to create a Zoo class, which keeps track of all the animals in the...
Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...
Provided code Animal.java: public class Animal { private String type; private double age; public Animal(String aT, double anA) { this.type = aT; if(anA >= 0) { this.age = anA; } } public String getType() { return this.type; } public double getAge() { return this.age; } } Provided code Zoo.java: public class Zoo {...
Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...
I need some help i need to do this in C# Objectives: • Create an application that uses a dictionary collection to store information about an object. • Understanding of abstract classes and how to use them • Utilize override with an abstract class • Understanding of Interfaces and how to use them • Implement an Interface to create a “contract” between classes. • Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the...
UML Class Diagram with Inheritance Objectives Use UML Correctly indicate inheritance Demonstrate permissions Understand inheritance relationships Labwork Please read all of the directions carefully. You will create a UML class diagram reflecting the class hierarchy for a fictional program that manages university personnel as constructed according to the graph displayed below. You will need to think about the attributes and behaviors that are unique to each class, and also those attributes and behaviors that are common amongst the subclasses and...
i have problem trying to create the class in this python 3 promblem In this problem you will be creating a Caterpillar class that will draw a caterpillar using turtle graphics. Your caterpillar object will contain the following information: 1. Body color (default "green") 2. Legs color (default "purple") 3. Body size (the radius of the 5 circles that make the caterpillars body) (default- 50) You are going to want to create a turtle object that you will use to...
The U of C graduating class of 2019 elects to give Hyde Park a tiny zoo with two adorable pandas. The zoo and pandas cost a total of 10 million dollars. There is no admission charge, and the equilibrium line length to see the pandas is 10 minutes. Professor Landsburg* visits the campus, and he notes that instead of going to see the pandas, Hyde Park residents always have the option of going to the lakeside, which is large enough...
Question 51 2 pts Which moral stance is taken toward the rights of animals by William Baxter? o Other animals have no rights at all--only human beings have rights. Except for rights like voting, humans and animals have the same rights. The fact that animals come from different species is morally irrelevant The rights of animals are extremely limited, mostly just the right to life. Question 52 2 pts In regard to the rights of animals, which is morally permissible...
IN C# Objectives: Create an application that uses a dictionary collection to store information about an object. Understanding of abstract classes and how to use them Utilize override with an abstract class Understanding of Interfaces and how to use them Implement an Interface to create a “contract” between classes. Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the following: Dictionary<string, string> Behaviors{ get; set; } string Perform(String signal); string Train(String signal, string behavior);...