Fishing simulation assignment

Assignment Help Programming Languages
Reference no: EM133153423

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

Questions Cloud

Information presented on statement of cash flows : Describe the information presented on the statement of cash flows. Why is this information important for the stakeholders of a corporation?
Analyzing the different companies and performances : Big data and data analytics are becoming an important part of an accountant's methods for analyzing the different companies and their performances
What percentage of their Social Security benefits is taxable : Social Security $18,000 They did not have any adjustments to income. What percentage of their Social Security benefits is taxable
Identify and describe two organisational learning theories : Describe the contemporary approach of design thinking to organisational learning strategy development and Identify and describe two organisational learning
Fishing simulation assignment : Develop a program that simulates fishing - There are 6 fish species in the river which you may catch
What is the amount of joint cost applied : After the additional processing, Far Side can sell the red pigment for$15/lb and the blue pigment for $20/lb. What is the amount of joint cost applied
Calculate the average days to collect receivables : By dividing 365 by your ratios from requirement 1, calculate the average days to collect receivables and the average days to sell inventory
What is the activity rate for the Setups activity : Assume a company's activity-based costing system includes three activities. What is the activity rate for the Setups activity
Writing a data analytical report to provide useful insights : Writing a data analytical report to provide useful insights, pattern and trends in a chosen dataset in the light of a set of tasks required within this document

Reviews

Write a Review

Programming Languages Questions & Answers

  Write function to merge contents of two sorted arrays

Write a function which will merge contents of two sorted (ascending order) arrays of type FLOAT values, use efficient bubble sort to sort two arrays first and then use merger function.

  Create a subdirectory in your repository

CMPT 214: Programming Principles and Practice Assignment. Create a subdirectory in your repository for a new project called Lab09

  Create sample input data then check answers with calculator

Create sample input data, run the program, then check your answers with a calculator or Excel. If something did not match up, then fix your program.

  Write program to compute diameter in centimeters

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  Write a program that prompts user to enter names of colors

Write a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than red, blue, or yellow.

  Write an if-then statement for the following code

Write an array that stores the square of the numbers from 1 to 5 in each element. Write out each element.

  Create a program that uses the same formula

Create a program that uses the same formula above to output the result; this time, however, prompt the user for the values a, b, x, and y.

  Implement an agent that plays the max-connect game

The task in this programming assignment is to implement an agent that plays the Max-Connect4 game using search. Figure 1 shows the first few moves of a game. The game is played on a 6x7 grid, with six rows and seven columns

  Illustrate whether program will fit in address space

Will this program fit in address space? If page size were 512 bytes, would it fit? Remember that page may not contain parts of two different segments.

  Write a program to input the temperature in celsius

Write a program to input the temperature in Celsius and convert it to Fahrenheit. Try your program with C = -40°, C = 20°, and C = 100°

  Write the application using the one-dimensional array

Write the application using the one-dimensional array which inputs ten numbers from user, each number can be between and 100, inclusive.

  Utilizes a good design process and incorporates sequential

Your final project will be to analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements.

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