Turtle - /** * Class that represents a turtle which is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /** * Class that represents a turtle which is similar to a Logo turtle. * This class inherts from SimpleTurtle and is for students * to add methods to. * * Copyright Georgia Institute of Technology 2004 * @author Barb Ericson ericson@cc.gatech.edu */ public class Turtle extends SimpleTurtle { ////////////////// constructors /////////////////////// /** Constructor that takes the x and y and a picture to * draw on * @param x the starting x position * @param y the starting y position * @param picture the picture to draw on */ public Turtle (int x, int y, Picture picture) { // let the parent constructor handle it super(x,y,picture); } /** Constructor that takes the x and y and a model * display to draw it on * @param x the starting x position * @param y the starting y position * @param modelDisplayer the thing that displays the model */ public Turtle (int x, int y, ModelDisplay modelDisplayer) { // let the parent constructor handle it super(x,y,modelDisplayer); } /** Constructor that takes the model display * @param modelDisplay the thing that displays the model */ public Turtle (ModelDisplay modelDisplay) { // let the parent constructor handle it super(modelDisplay); } /** * Constructor that takes a picture to draw on * @param p the picture to draw on */ public Turtle (Picture p) { // let the parent constructor handle it super(p); } /////////////////// methods /////////////////////// public void drawHexagon(int length) { length = 100; this.turn(-60); this.forward(length); this.turn(-60); this.forward(length); this.turn(-60); this.forward(length); this.turn(-60); this.forward(length); this.turn(-60 ); this.forward(length); this.turn(-60 ); t this.forward(length); } public void drawS(int size) { s size = 20; this.turnLeft(); this.forward(size); this.turnLeft(); this.forward(size); this.turnLeft(); this.forward(size); this.turnRight(); this.forward(size); this.turnRight(); this.forward(size); } public void drawT(int size) { size = 20; this.turnLeft(); this.forward(size); this.turn(180); this.forward(size*2); this.turn(180); this.forward(size); this.turnLeft(); this.forward(size*2); } public void drawO(int size) { size = 20; this.turnLeft(); this.forward(size*2); this.turnLeft(); this.forward(size*2); this.turnLeft(); this.forward(size*2); this.turnLeft(); this.forward(size*2); } public void drawP(int size) { size = 20; this.turnRight(); this.forward(size); this.turnRight(); this.forward(size); this.turnRight(); this.forward(size); this.turnLeft(); this.forward(size); this.turn(180); t this.forward(size*2); } } // end of class Turtle, put all new methods before this ...
View Full Document

This note was uploaded on 12/20/2009 for the course COMP SCI 026 taught by Professor Unknown during the Spring '07 term at UWO.

Ask a homework question - tutors are online