How to create function that simulate fishing based on fish object from the different fish classes?

Viewed 50

I am creating a program that simulates the fishing 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).

I have created two python files as fish_species.py and fishing.py. The fish_species.py has all the classes of different species of fish like:

fish_species.py

class AustrialianBass : 

  MAX_WEIGHT=4000 
  MAX_EATING_WEIGHT = 2500 
  NAME = 'Austrialian Bass'
  LATIN_NAME = 'Macquaria Novemaculeata'
  
  def __init__(self, weight):
    self.weight = weight
  
  def __str__(self):
    return '{} ({}) , weights {} kg'.format(self.NAME, self.LATIN_NAME, self.weight/1000)

  def is_good_eating(self): 
    if self.weight >= 500 and self.weight <= self.MAX_EATING_WEIGHT:
      return True

  
class ShortFinnedEel : 

  MAX_WEIGHT=3000
  MAX_EATING_WEIGHT = 3000
  NAME = 'Short Finned Eel'
  LATIN_NAME = 'Anguilla Australis'
  
  def __init__(self, weight):
    self.weight = weight
  
  def __str__(self):
    return '{} ({}) , weights {} kg'.format(self.NAME, self.LATIN_NAME, self.weight/1000)

  def is_good_eating(self): 
    if self.weight >= 500 and self.weight <= self.MAX_EATING_WEIGHT:
      return True

class GippslandPerch  : 

  MAX_WEIGHT=10,000
  MAX_EATING_WEIGHT = 6000
  NAME = 'Gippsland Perch '
  LATIN_NAME = 'Macquaria Colonorum'
  
  def __init__(self, weight):
    self.weight = weight
  
  def __str__(self):
    return '{} ({}) , weights {} kg'.format(self.NAME, self.LATIN_NAME, self.weight/1000)

  def is_good_eating(self): 
    if self.weight >= 500 and self.weight <= self.MAX_EATING_WEIGHT:
      return True

class EelTailedCatfish  : 

  MAX_WEIGHT=6800
  MAX_EATING_WEIGHT = 4000
  NAME = 'Eel Tailed Catfish '
  LATIN_NAME = 'Tandanus Tandanus'
  
  def __init__(self, weight):
    self.weight = weight
  
  def __str__(self):
    return '{} ({}) , weights {} kg'.format(self.NAME, self.LATIN_NAME, self.weight/1000)

  def is_good_eating(self): 
    if self.weight >= 500 and self.weight <= self.MAX_EATING_WEIGHT:
      return True
  

class GoldenPerch  : 

  MAX_WEIGHT=9000
  MAX_EATING_WEIGHT = 2000
  NAME = 'Golden perch '
  LATIN_NAME = 'Macquaria ambigua'
  
  def __init__(self, weight):
    self.weight = weight
  
  def __str__(self):
    return '{} ({}) , weights {} kg'.format(self.NAME, self.LATIN_NAME, self.weight/1000)

  def is_good_eating(self): 
    if self.weight >= 500 and self.weight <= self.MAX_EATING_WEIGHT:
      return True

class SouthernSaratoga  : 

  MAX_WEIGHT=4000
  MAX_EATING_WEIGHT = 2500
  NAME = 'Southern Saratoga '
  LATIN_NAME = 'Scleropages leichardti'
  
  def __init__(self, weight):
    self.weight = weight
  
  def __str__(self):
    return '{} ({}) , weights {} kg'.format(self.NAME, self.LATIN_NAME, self.weight/1000)

  def is_good_eating(self): 
    if self.weight >= 500 and self.weight <= self.MAX_EATING_WEIGHT:
      return True

How to design the function to simulate the fishes every second it is caught and if the created fish object is_good_eating, the object is added to the basket, otherwise, fish is released( not added to the baseket). Once total weight of fishes in the basket exceeds 25 kg (2500g), the basket is returend (fishing ends).

I have tried to build the function according to above criteria, but i don't know solve this problem.

fishing.py

import random
import fish_species
import time
species = [
    fish_species.AustrialianBass,
    fish_species.EelTailedCatfish,
    fish_species.GippslandPerch,
    fish_species.GoldenPerch,
    fish_species.ShortFinnedEel,
    fish_species.SouthernSaratoga
]
fishes = []

def starting_fishing():
    for i in range(6):
        #choose a random species (between 0 and 5)
        caught = species[random.randrange(0,6)]
        #create and append a fish with random weight
        fishes.append(caught(random.randint(0,caught.MAX_WEIGHT)))    

Please can anyone help to solve this problem?

0 Answers
Related