Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Python 2.7 or Python 3.4 In this assignment, you are going to design and implement an interactive zoo records database. This will be

Please use Python 2.7 or Python 3.4

In this assignment, you are going to design and implement an interactive zoo records database. This will be an object-oriented program that processes a file of zoo animal data and interactively answers queries from a user. The challenge in this assignment is to implement the database using inheritance.

1. File Input Specification:

The first line of each animal data record in the input file is in the following format:

Name AnimalType Species Mass

Explanation:

o Name: The animals individual name. Contains no white space.

o AnimalType: The type of animal. One of: Mammal, Reptile, Bird

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

Oliver Bird Ostrich 75

The data following the first line in each animal record depends on the AnimalType:

Mammals:

o The first line of data for animals of type Mammal is followed by:LitterSize

o Explanation: LitterSize is the average number of offspring the mammal has. A whole number 1

Reptiles:

o The first line of data for animals of type Reptile is followed by: VenomousOrNot

o Explanation: VenomousOrNot: Indicates whether the reptile has a venomous bite. One of: Venomous, Nonvenomous

Birds:

o The first line of data for animals of type Bird is followed by: Wingspan Talks Or Mute

o Explanation:

o Wingspan: The wingspan of the bird in inches. A whole number 1

o TalksOrMute: Indicates whether the bird talks. One of: Talks, Mute

o Finally, birds that talk have an additional line of data:Phrase

o Explanation:Phrase: What the bird says. May contain whitespace, but is no more than one line long.

2. Example Data File:

Provided with the assignment names: zoo.txt

Here is an example of a data file to be read by the program: (This is the 'zoo.txt' file)

Bob Mammal Bear 300 2

Lucy Reptile Lizard 2

Nonvenomous

Carl Reptile Cottonmouth 3

Venomous Oliver Bird Ostrich 75

60 Mute

Polly Bird Parrot 1

2 Talks

I want a cracker

Doug Mammal Dog 20

4

For this exercise, assume that each animal has a unique name

2. Program Output and Behavior Specification: Once the program has read in the data file, it should request and process interactive queries from the user. It should request queries in the following format:

Zoo data read in.

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]?

The user interactively queries the database for information on individual animals. The following example demonstrates all varieties of queries and responses, using the data provided in the above example file. (user input shown in bold,underlined,italic font)

Zoo data read in.

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? s

Animal Name? Bob

Bob species is Bear

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? m

Animal Name? Lucy

Lucy mass is 2

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? l

Animal Name? Bob

Bob litter size is 2

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? v

Animal Name? Carl

Carl is Venomous

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? v

Animal Name? Lucy

Lucy is Nonvenomous

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? w

Animal Name? Oliver

Oliver Wing Span is 60

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? t

Animal Name? Oliver

Oliver is Mute

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? t

Animal Name? Polly

Polly talks.

Polly says I want a cracker

Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? e

Goodbye!

3. Program Structure: The program must use an object oriented approach with inheritance. Specifically, classes representing animals, mammals, reptiles, birds, and talking birds should be employed to store each animals data, implementing appropriate inheritance, and providing methods to return and/or output query responses.

4. Error Handling:

For this exercise, you can assume that the data input file is properly formatted. In addition, you may assume that users will only query litter size for mammals, venom status for reptiles, and wingspan and talkativeness for birds. However, the program should gracefully handle cases in which a user does not respond with one of s, m, l, v, w, t, or e to the programs query request, or provides the name of an animal not in the database

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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