Open Shreeyak opened 7 years ago
It would be better if the python program were to use the Robot class's sLocation member to keep track of where the robot is, and having the functions modify that member instead of returning the location. Hence, program would look like this:
startLocation=[0,0,'S']
r1 = util.Robot(startLocation) r1.rotate( 'N') r1.moveFoward(5) r1.rotate('E') r1.moveFoward(15)
r1.printInfo()
Looks better, makes uses of the constructor and printInfo (which aren't being used now) and makes more sense to the robot.
Good point. I will keep in mind as I work on course changes.
It would be better if the python program were to use the Robot class's sLocation member to keep track of where the robot is, and having the functions modify that member instead of returning the location. Hence, program would look like this:
use lists instead of tuples
startLocation=[0,0,'S']
r1 = util.Robot(startLocation) r1.rotate( 'N') r1.moveFoward(5) r1.rotate('E') r1.moveFoward(15)
TODO: print robot's end location
endLocation should be (15,5,E)
r1.printInfo()
Looks better, makes uses of the constructor and printInfo (which aren't being used now) and makes more sense to the robot.