Week 11 Lab: Better Scribbler Movement

For this lab, you are going to write code to make your Scribbler robot be able to go to certain locations on the whiteboard, using some classes.

Step 1: Make the lab11 folder, etc.

Open Eclipse and make sure you are in the workspace S:\workspace. Make a lab11 folder. Then ***copy*** the move.py file over from your lab7 folder into your lab11 folder. (move.py should be unchanged from lab7.)

Make a new file called scribpoint.py. Put this new class definition into it:

class ScribPoint:
    def __init__(self):
        self.x = 0
        self.y = 0

This class will represent an (x, y) coordinate on a whiteboard on the floor where the Scribbler is, or will go to. Initially, the point being represented is (0, 0).

Step 2: Adding getter and setter methods

Now, add the getter and setter methods for x and y. Call them, getX(), getY(), setX(), and setY().

Step 3: Import scribpoint into move.py

Open the move.py file. At this point, I recommend that you only have one move.py file open in Eclipse. If you have two of them open (one from lab11) you might edit the wrong one.

Now, in move.py, at the top by the other imports, put this:

from scribpoint import *

Step 4: New function goToPoint()

In move.py, we are going to add a new function, goToPoint(), to make a Scribbler robot go to a point on the x,y coordinate plane.

Name goToPoint Makes a Scribbler robot move from where it is (located in start), to a new point end.
Parameters

start: a ScribPoint object
end: a ScribPoint object

 
Return Value None  

Step 5: Add code to test goToPoint()

Now, create a file lab11.py. At the top of that, add the magic code to import __future__ stuff. Then, add the line to import move, like we've been doing.

Add code to lab11.py to:

Put a marker in your Scribbler and run your code. See if your line segment is close to the 20 cm. It should be.

Create more ScribPoint() objects and to test your goToPoint() to make sure it really works.

Step 6: Draw a 5 point Star

***Replace*** the code you have in lab11.py with code to draw a 5-pt star with these points

Remember that where ever you put the Scribbler down is point (0, 0), and whichever direction you have it facing is the +x axis. Also, you don't really want to draw a line from (0, 0) to (5, 20). So, you'll have to make some adjustments to get this to work.

Step 5: Submit your code

Clean up any code in lab11.py that isn't relevant anymore (old print statements, etc.) Make sure your code is well-documented, indented, hospitable, etc. Make sure you have the correct information in it about you, the author.

To submit your final version of lab11.py and move.py, you’ll need to use Windows Explorer.


Grading Rubric: 15 points total

10 points: program that runs correctly.  There are many parts to handle in this program, so make sure all work correctly.
1 points: correct comments at the top of the file.
4 points: code is clean and neat and uses good comments and variable names. I.e., the code is hospitable.