Using passing multple variables into a python object -
i'm having issues understanding should here. need create object using class runner:
, run()
method. part of code stumping me part:
colora,turtlea,yourname = obja.run() colorb,turtleb,yourname = objb.run()
i love ideas on how done. have simple class set up. have:
import turtle class runner: def __init__(self,color): self.color = color def run(self): self = turtle.turtle(), "michael corbett"
full proj02 code:
from proj02runner import runner import turtle window = turtle.screen() turtle.setup(300,200) obja = runner("red") #create 1 object objb = runner("green") #create second object #call run method on each object , unpack # tuple returned. colora,turtlea,yourname = obja.run() colorb,turtleb,yourname = objb.run() window.title(yourname) #manipulate turtles draw picture. turtlea.left(90) turtlea.stamp() turtlea.right(90) turtlea.forward(50) turtlea.right(30) turtlea.color(colora) turtlea.forward(50) turtleb.right(180) turtleb.forward(50) turtleb.left(30) turtleb.color(colorb) turtleb.forward(50)
make run
method this:
def run(self): return self.color, turtle.turtle(), "michael corbett"
Comments
Post a Comment