Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!