The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Use Python:
In this lab,
Use classes to create a virtual aquarium, and then manipulate it using a simple sorting algorithm known as "bubble sort".
1. Start by defining a new Fish class, which will represent a single fish in our aquarium. A Fish has four instance variables (its name, its species, its color, and its weight in ounces). Every Fish also has the following methods (with the following headers):
   a. __init__(self, name, species, color, weight)
   This method creates four new instance variables for the Fish, and assigns them the values of the last four method parameters. Remember that an instance variable's name is always preceded by "self.", as in self.myData.Â
   b. __repr__(self)
   This method returns a string representing the current Fish. This string should include a crude fish symbol (<><) followed by the Fish's name, color, and species in parentheses. For example: <>< (Topper, blue Guppy)Â
   c. __lt__(self, other)Â
   This method returns True if the current Fish's weight is less than the other Fish's weight instance variable, and False otherwise. Remember that Python does not protect instance variables from outside access, so you can directly refer to, for example, other.weight.Â
   d. kind(self)
   This method returns the species of the current Fish.
.........(in Lab 7.PDF attached)
# CSE 101 Lab 7
# Name:
# SBU ID #
# ADD YOUR CLASS DEFINITIONS HERE
# ADD YOUR DRIVER CODE HERE
if __name__ == "__main__":
   cap = int(input("How many gallons of water can the tank hold? "))
   source = input("Enter the name of the file containing the list of fish: ")
   # ADD THE REST OF YOUR CODE HERE
Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly