I have to make my own turtle class without using the "from turtle import *" line.
This is the code i have so far:
from graphics import * class Turtle: '''The turtle''' def __init__(self, win, defstep, defwidth, defangle, startpt, startangle): '''initialize the turtle - win: window to draw - defstep: default stepsize - defangle: default angle - startpt: the starting position - startangle: the starting orientation angle ''' pass def step(self, penDown): '''make a step (draw if penDown==True) and update the state''' pass def rotate(self, angle): pass def scale(self, scalefactor): pass def draw(self, str): line = Line ( firstPoint, secondPoint) line.setWidth(self.state.width) line.draw(self.win) '''This function does the interpretation of the LS string str. Loop over characters in the str using the parseArg function. Every call to parseArg will return three values c,par,nextindex. Decide what to do for every character c (and use the right argument if an argument was given and found in the string). To draw a line: line = Line( firstPoint, secondPoint) line.setOutline(r,g,b) line.setWidth(self.state.width) line.draw(self.win) This is also the function where you need the Stack class. When you encounter the '[' character you have to push the state and when you encounter the ']' character you have to pop a state from the stack. Please be aware not to push a reference to the state on the stack (you will be overwriting it). I advise to have a method clone in the State class that really makes a new state object that you can safely push on the stack. ''' pass
Do any of you have any tips on how to start this?