Part A. P3.14 from your textbook, without the “extra credit” part.

Draft: Just provide stubs for all methods, where accessor methods return 0 and mutators do nothing.

Put your work in a class VotingMachine.

netbrat draft | final

Part B. P3.11 from your textbook.

Draft: Just provide stubs for all methods, where accessor methods return 0 and mutators do nothing.

Put your work in a class Bug.

netbrat draft | final

Part C. Modify P3.11 where the bug lives on a two-dimensional grid, not a line. The turn method turns clockwise by 90 degrees. Replace getPosition by getX and getY. Supply a single constructor that places the bug at the origin and moves to the right.

Put your work in a class Bug2.

Sample usage:

Bug2 superBug = new Bug2(); // Position (0, 0)
superBug.move(); // Position (1, 0)
superBug.move(); // Position (2, 0)
superBug.turn(); // Position still (2, 0)
superBug.move(); // Position (2, -1)

The trick is to update the directions in the turn method.

In your linear algebra class, you will learn how to do this with a rotation matrix. Here is the formula:

newDx = dy
newDy = -dx
dx = newDx
dy = newDy

netbrat draft | final

You submit three Java files to Canvas:

Note that you must submit to Canvas. netbrat is anonymous and has no connection to the gradebook.