import java.awt.Color; import edu.princeton.cs.algs4.Draw; public class Turtle { private Draw draw; private Color color; // TODO: You
Question:
import java.awt.Color; import edu.princeton.cs.algs4.Draw;
public class Turtle { private Draw draw; private Color color; // TODO: You will need to add more private fields (object variables) here. /** * Create a new Turtle for a given Draw object with a given pen color. * The Turtle always begins at (0, 0) facing 'u' (up). * * @param d the Draw object on which the Turtle will move and draw. * @param c the color of the Turtle's pen. */ public Turtle(Draw d, Color c) { draw = d; color = c; // TODO: You will need to initialize here any extra fields you add to the Turtle class } /** * Get the x coordinate of the turtle's current location. * @return the x coordinate of the turtle's current location. */ public int getX() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Get the y coordinate of the turtle's current location. * @return the y coordinate of the turtle's current location. */ public int getY() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Get the direction the turtle is facing (up, down, left, or right) * * @return the first letter of the direction the turtle is facing (u, d, l, or r). */ public char getDir() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Turn the turtle 90 degrees to its left (counter clockwise). */ public void turnLeft() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Turn the turtle 90 degrees to its right (clockwise). */ public void turnRight() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Move the turtle the given amount in the direction it is facing. * If the pen is in the down position, this causes a line to be drawn * in the pen's color. * * @param amount the distance the turtle is to move. */ public void move(int amount) { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Places the pen in the up position. Movement will not cause * a line a to be drawn while the pen is in the up position. */ public void raisePen() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } /** * Places the pen in the down position. Movement will cause * a line a to be drawn while the pen is in the down position. */ public void lowerPen() { // TODO Remove the exception and replace with appropriate code. throw new RuntimeException("Not Implemented"); } }
Computer Graphics Programming In OpenGL With JAVA
ISBN: 9781683922193
2nd Edition
Authors: V. Scott Gordon PhD, John L. Clevenger PhD