Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON: This assignment will have you read information in from various files, perform exception handling when reading those files, and create a base class

IN PYTHON:

This assignment will have you read information in from various files, perform exception handling when reading those files, and create a base class and derived classes (no concept of virtual functions in python) to read the various files, perform some computations on the inputs as described below, and print the file details

For this assignment, create a base class called Animal. It should have as member variables any variables that are contained across all animals in this assignment along with any associated mutator and accessor member functions. You will create a derived class for each of the following: dog, fish, horse, monkey and lizard. The member functions to read and output the objects information will be virtual functions. Each derived class must contain the additional member variables and member functions needed to include all fields in each input file.

Each input file will contain data about one object; you will not be required to read in information about multiple objects from one file.

I have included one sample file for each of the five animal types. When I am testing your code, I will be using additional files with errors to see how you have implemented exception handling and gracefully recover. You may want to create additional files for your testing.

In your main, create an object of each derived class type, read in the object information from the provided files to populate the objects using the derived virtual read function. For the dog, subtract 10 pounds from its weight; for the horse, add one hand to its height; for the monkey, change its endangered flag (if endangered, make it not endangered; if not endangered, make it endangered). Finally, use the virtual print function to print to the screen the information about each animal.

Your main should create an object of each of the derived class types, use the readfile function of each object to read the files, call the subtract10 function for the dog, the add1 function for the horse, and the changeEndangered function for the monkey, and then use the overridden print function of each derived class to output the information about each animal.

These files are .csv files. You should read in but ignore the first line, as it contains the column headers. The second line contains comma-separated values. Consider reading in each row with a for loopwhich is essentially a for each rowthen parse individual variables by using the .split(,);

File contents: Dog.csv: name, breed, age, color, weight Fish.csv: name, color, freshwater?, habitat, predator? Horse.csv: name, color (body color), maneColor, age, height Lizard.csv: name, color, habitat, protected?, weight Monkey.csv: name, color, age, wild?, home, endangered?

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions