Develop a module named fishing

Assignment Help Other Subject
Reference no: EM133154327

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

Questions Cloud

Describes New Jihad : Describes 'New Jihad." When did this movement begin, and why it is important?
Did watts behavior constitute intentional tort : Did Watts's behavior constitute intentional tort or tort of negligence? What is the key factor in determining whether Buy-Mart is liable under this doctrine?
Generate a random fish and weight : Generate a random fish and weight, you are supposed to use the "randrange" function from the "random" package.
Personal bankruptcy : Under the Bankruptcy Code after the reform act, what must Janet do before filing a petition for relief under Chapter 7?
Develop a module named fishing : Develop a module named fishing (file "fishing.py"). This module should import the module "fish_species", so you can use the class definitions from
Liable for the tort committed by watts : Under what doctrine discussed in this chapter might Buy-Mart be held liable for the tort committed by Watts?
How does anger regulate aggression : How does anger regulate aggression? Describe the differences in anger management between under controlled and overcontrolled offenders.
What is an example of a company that leverages : What is an example of a company that leverages its logistics and developed it into a competitive advantage.
Shallow discussions of several concepts : Considering all the concepts you have learned in this course, what would you consider one of your most significant takeaways, and why?

Reviews

Write a Review

Other Subject Questions & Answers

  Review problem based on the disabilities

A voluntary self-identification form required by the Office of Federal Contract Compliance Programs (OFCCP) for federal contractors asks job applicants.

  Strengths and weaknesses of progressivism

Evaluate the strengths and weaknesses of progressivism. In what ways were mobilization and the war effort a fulfillment of the progressive legacy? In what ways did the war deny the basic tenets of progressivism?

  How has outbreak of covid-19 impacted on the health sector

How has the outbreak of Covid-19 impacted on the health sector? (Example on demand and supply of medicines, hospital services, government expenditure on the

  Define what makes body piercings appealing

Define What makes body piercings appealing, What makes body piercings unappealing

  Evaluate the effect the ebp project issue is having

How current is the science underlying the practices related to your EBP Project issue? Evaluate the effect the EBP Project issue is having in practice.

  Consequences in the aftermath of a divorce

As we have seen, children suffer many consequences in the aftermath of a divorce. What steps could be taken to lessen the trauma of divorce for children?

  What role does leadership play in improving care

What role does leadership play in improving care? How does this relate to nursing as a profession, as well as to an individual nurse?

  Describe an appropriate and effective leadership style

Recommends an appropriate and effective leadership style that superiors at the organization could employ to address the problem and best fit the organization.

  How to improve your own immunity

How to improve your own immunity and prevent the spread of the virus (Covid-19). Write a 3-page double spaced (maximum) paper on a topic that presents.

  Discuss local law enforcement agencies are using drones

Local law enforcement agencies are increasingly using drones With their cameras and heat sensors

  State why you think the material relates to the main theme

You should say who created the material you are analyzing, who published the material, and a general statement about what the material is about.

  What are the six stages of the revenue cycle

What are the six stages of the revenue cycle? Assume that a certain nursing home has two categories of payers. Medicaid pays $60.00 per day and private pay patients pay the established per diem, but approximately 10 percent of private-pay charges are..

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