Develop a module named fish_species

Assignment Help Programming Languages
Reference no: EM133155432

ITECH 1400 Foundations of Programming - Fishing Simulation

Introduction: In this assignment you are required to develop a program that simulates fishing: There are 6 fish species in the river which you may catch:

- Australian Bass (Macquaria Novemaculeata) - commonly less than 4 Kg; excellent eating, when less than 2.5 Kg.
- Short Finned Eel (Anguilla Australis)- commonly less than 3 Kg; a good eating fish.
- Eel Tailed Catfish (Tandanus Tandanus) - Up to 6.8 Kg; excellent eating, when less than 4 Kg.
- Gippsland Perch (Macquaria Colonorum)- commonly less than 10 Kg; excellent eating when up to 6 Kg.
- Two more species you should add to this list yourself. Search the internet for the necessary details.

Your program should be based on the following assumptions:
- Every second you catch a fish (perfect fishing).
- The chances (probabilities) to catch each of these six species are equal.
- Weights of fishes of the same species are distributed evenly and range from 0 to the Maximal Weight. The value of Maximal Weight for each of the species is given above. For example, Maximal Weight of Australian Bass is 4 Kg.
- Fishing starts with an empty basket which you should implement as a list. If you catch a fish with a weight greater than 500 g or less than the recommended excellent eating maximum, you add it to the basket. Otherwise, release it. For example, only instances of Australian Bass with the weights between 0.5 Kg and 2.5 Kg should be added to the basket.
- Stop fishing immediately as soon as the total weight of all the fishes in the basket exceeds 25 Kg.

To generate a random fish and weight, you are supposed to use the "randrange" function from the "random" package.
Fishes of different species must be implemented as objects of the corresponding classes.
For convenience, all weights appearing in the program body should be integers given in grams e.g. instead of 3 Kg you should use 3000g. However, when printing outputs on the screen you may use kilograms.

Question 2. Develop a module named fish_species (file "fish_species.py"). This module should contain definitions of the following six classes: AustralianBass, ShortFinnedEel, EelTailedCatfish, GippslandPerch + 2 more classes for the species you add yourself.

class AustralianBass should contain the following members:

- Variables (Constants):
- MAX_WEIGHT = 4000
- MAX_EATING_WEIGHT = 2500
- NAME = 'Australian Bass'
- LATIN_NAME = 'Macquaria Novemaculeata'
- The constructor should define and initialise a single attribute named "weight". The attribute weight must get an integer value between 0 and MAX_WEIGHT.
- A method named "is_good_eating": returns True if the fish's weight is between 500 g and excellent eating weight (2500 g for Australian Bass).
- An overridden (redefined) method " str " that returns a nice, readable string representation of a fish object. Here's an example:

Other fish classes should have similar, mutatis mutandis, implementations.

Question 3. Develop a module named "fishing" (file "fishing.py"). This module should import the module "fish_species", so you can use the class definitions from it. In addition, in this module you should define the following functions:

Function start_fishing().

The function simulates fishing process in the following way:
- Every second a random fish is "caught". I.e., every second the program randomly chooses one of the 6 fish species, then randomly generates a weight within valid range (between 0 and the species' MAX_WEIGHT), and then creates the corresponding fish object.
- If the created fish object is_good_eating, the object is added to the basket (implemented as a list). Otherwise, the fish is released, i.e., is not added to the basket.
- Once total weight of fishes in the basket exceeds 25 Kg (25000 g), the basket is returned (fishing ends).

- Fishing results should be printed on the screen, one line per second.
- Here's a sample output:

Note. To pause your function's execution for 1 second use time.sleep(1) function from the time package.

Function print_basket(basket).
The function prints its argument's (basket's) content on the screen as shown below:

Function plot_basket(basket).

The function plots a bar-chart that shows total weights of each of the species in the basket:

Note. In the examples above only four species of fishes are used. However, in your program you should have 6 species!

Functions save_basket(basket, file_name) and load_basket(file_name).

In this task you must:
- search Python documentation to find out how to use the pickle package in order to save Python objects to files and load the saved objects back to programs.
- save_basket(basket, file_name) - using pickle.dump saves the basket to a binary file with the specified name.
- load_basket(file_name) - using pickle.load loads a saved object (basket) from the specified file.

Attachment:- Fishing_Simulation.rar

Reference no: EM133155432

Questions Cloud

What size of the deposit peter makes while he is saving : He saves for 18 years, and then converts his savings into an annuity that pays him $300. What size of the deposit Peter makes while he is saving
What is the estimated number of species for the family : What is the distribution of the family and What is the estimated number of species for the family
Explain emergence of terrorism after six-day war : Why is the Middle East a concept? Explain the emergence of terrorism after the Six-Day War.
Define the term electronic voting : Define the following terms: Copyrights, Patents and Trade Secrets. Define the term Electronic Voting. Describe two historical examples of cyber warfare.
Develop a module named fish_species : Develop a module named fish_species (file "fish_species.py"). This module should contain definitions of the following six classes
Juvenile Court System : Describe why you agree or disagree with what is reported about in the case. Present your analysis of the case.
Calculate the material price variance : Calculate material price variance and material quantity variance related to the M640 electrical relay. Indicate whether variances are favorable or unfavorable
Real reality for police work : Discuss what you consider to be the real reality for police work, incorporating your review of the assigned readings
Compute the labor rate and labor efficiency variances : Actual labor costs were $123,750 for 8,250 hours. Compute the labor rate and labor efficiency variances for the month of June

Reviews

Write a Review

Programming Languages Questions & Answers

  Do comments explain processing that is not obvious

When reviewing a program, these are the four criteria for style: Do identifiers logically describe use? Is indentation used correctly to illustrate the structure of the program?

  Two-dimensional array represent number of times bug reached

Two-dimensional array (N X M) must be utilized to represent number of times the bug reached each tile on floor. All cells of this array must be initialized to zero.

  Assignment - file access and pseudocode

Assignment - File Access and Pseudocode, When a program needs to save data for later use, it writes the data in a file. The data can be read from the file at a later time

  Estimate the storage space for telephone book

Estimate the storage space (number of bytes) required for each of the following items: A telephone book with 10,000 entries consisting of names, addresses and phone numbers. Use your phone book to estimate the average length of an entry.

  Program that calculate the average of a group of test scores

Write a program that calculate the average of a group of test scores, where the lowest score is dropped. It should use the following functions: void getScore() - should ask the user for a test score, store it in a reference parameter variable, and..

  Design a program that will allow a user to input

Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input?

  Features of object oriented programming

Write a 200- to 300-word short-answer response to the following: Describe the main features of Object Oriented Programming - Encapsulation, Inheritance and Polymorphism

  Create program to counts number of bytes located in memory

Create the program which Counts the number of bytes located in memory from DS:1000h to DS:1200h which are greater than 77h. Put the count on register CX.

  Design stored procedure to accept optional parameters

Design a stored procedure named spBalanceRange that accepts three optional parameters. Procedure returns a result set consisting of VendorName, InvoiceNumber and Balance for each invoice with a balance due

  Write a fraction class whose objects will represent fraction

Write a fraction class whose objects will represent fractions. You should provide the following member functions: Two constructors, a default constructor which assigns the value 0 to the fraction, and a constructor that takes two parameters.

  Program that uses for loop prompt user to input two integers

Write a program that uses for loop to preform the following steps: Prompt the user to input two integers: firstnum and secondnum.

  Demonstrates the use of two separate classes

Describe a real world application that demonstrates use of two separate classes. Write a switch statement that allow user to enter a number instead of a string.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd