In-class notes for 05/02/2014
CS 121B (CS1), Spring 2014
Submitted questions on assignments and technology
Optional argument for
Garden
constructorSpecs:
Plant
, originalGarden
, revision toGarden
,Solution:
from Plant import Plant class Garden: '''Represents a collection of biological plants State variable: plants - list of Plant objects''' def __init__(self, lis = []): self.plants = lis def getPlant(self, index): if index < 0 or index >= len(self.plants): return False return self.plants[index] def size(self): return len(self.plants) def addPlant(self, pl): self.plants = self.plants + [pl] return len(self.plants)-1 def main(): lis = [ Plant('white oak', 1900), Plant('tulip', 950) ] g1 = Garden(lis) g2 = Garden() print(g2.size()) tree = Plant('red oak', 1042) g2.addPlant(tree) g2.addPlant(Plant('rose', 2.7)) print(g2.size()) print(g2.getPlant(1)) print(g2.getPlant(1).getMass()) print(g2.getPlant(1).setMass(2.85)) print(g1.getPlant(0).getMass()) main()
Project team formation, proposals, feedback
Features list
Using objects
Next steps in project
As a team, please submit a planning sheet google doc and share it with Prof. Brown
See description of the planning sheet in "HW31" (not really a homework, just a convenient way to present it...)
Submit your google doc using a special title by sharing with two accounts for Prof. Brown, as described here
< >