#Accessor methods for Bird Sighting data attributes
def get_bird_species(self):
return self.__bird_species
def get_flock_size(self):
return self.__flock_size
- Write out the information from the text editor to the file by pressing Ctrl+O. The file name
shows along with the prompt File name to write. Press Enter to write out the
contents to the sightings.py object file. - Exit the nano text editor by pressing Ctrl+X.
- To modify the script to use these two objects, at the command-line prompt, type nano
py3prog/script1503.py and press Enter. - For the first change, in the Import Modules section of the script, under the import of the
SouthAfricanCliffSwallow object file, insert the following lines (which import the
new object files into the script):
Click here to view code image
# Sightings object file
from sightings import Sighting
#
# Birds sightings object file
from sightings import BirdSighting
- For the second change, in the Create Variables & Object Instances section
of the script, under the creation of both the barn and cliff swallow object instances, insert the
following lines, properly indented:
Click here to view code image
location='unknown' #Location of sighting
date='unknown' #Date of sighting
#
bird_sighting=BirdSighting(location,date,species,flock_size)
- For the third change, delete both the sections Obtain Flock Size and Mutate
Sighted Birds' Flock Size, along with their Python statements:
Click here to view code image
######## Obtain Flock Size #################
#
flock_size=int(input("Approximately, how many did you see? "))
#
###### Mutate Sighted Birds' Flock Size ####
#
if species == '1':
barn_swallow.set_flock_size(flock_size)
else:
sa_cliff_swallow.set_flock_size(flock_size)
#
- In place of what you just deleted, add the following:
Click here to view code image
######## Obtain Sighting Information #################