Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Complete the createFish() function, which takes a single string argument in the form: species name color weight where each field is separated by a

2. Complete the createFish() function, which takes a single string argument in the form: species name color weight where each field is separated by a single space (assume that the species and name are always single-word values). This function should create and return a new Fish object whose attributes are based on the contents of this string. Note that the fields of the string are in a slightly different order than the argument list of the Fish class, and that the weight value must be converted from a string to a float value before the new Fish is created.

4. Finally, complete the fillAquarium() function. This function takes two arguments: a string representing the name of a (plain text) data file, and a positive (non-zero) integer representing the tank capacity in gallons. It returns a new Aquarium object. fillAquarium() does the following: (a) It creates a new Aquarium with the specified capacity. (b) It uses a loop to open the specified data file. For each line in the data file: The function calls createFish() with the current line to get a new Fish. The function attempts to add the new Fish to the Aquarium object. (c) It returns the new Aquarium.

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions