Show
Class that represents a Logo-style turtle. The turtle starts off facing north. A turtle can have a name, has a starting x and y position, has a heading, has a width, has a height, has a visible flag, has a body color, can have a shell color, and has a pen. The turtle will not go beyond the model display or picture boundaries. You can display this turtle in either a picture or in a class that implements ModelDisplay. Copyright Georgia Institute of Technology 2004 Author:Barb Ericson [email protected]Constructor Summary public double getDistance(int x, int y)0 Constructor that takes the x and y position for the turtle public double getDistance(int x, int y)1 Constructor that takes the x and y position and the model displayer public double getDistance(int x, int y)2 Constructor that takes the x and y position and the picture to draw on public double getDistance(int x, int y)3 Constructor that takes a model display and adds a turtle in the middle of it public double getDistance(int x, int y)4 Constructor that takes the picture to draw on and will appear in the middle Method Summary public double getDistance(int x, int y)5 public double getDistance(int x, int y)6 Method to go backward by 100 pixels public double getDistance(int x, int y)5 public double getDistance(int x, int y)8 Method to go backward a given number of pixels public double getDistance(int x, int y)5 public void turnToFace(SimpleTurtle turtle)0 Method to clear the path (history of where the turtle has been) public double getDistance(int x, int y)5 public void turnToFace(SimpleTurtle turtle)2 Method to draw the information string public double getDistance(int x, int y)5 public void turnToFace(SimpleTurtle turtle)4 Method to draw a passed picture at the current turtle location and rotation in a picture or model display public double getDistance(int x, int y)5 public void turnToFace(SimpleTurtle turtle)6 Method to move the turtle foward 100 pixels public double getDistance(int x, int y)5 public void turnToFace(SimpleTurtle turtle)8 Method to move the turtle forward the given number of pixels public void turnToFace(SimpleTurtle turtle)9 public void turnToFace(int x, int y)0 Method to get the body color public void turnToFace(int x, int y)1 public void turnToFace(int x, int y)2 Get the distance from the passed x and y location public void turnToFace(int x, int y)1 public void turnToFace(int x, int y)4 Method to get the current heading public void turnToFace(int x, int y)5 public void turnToFace(int x, int y)6 Method to return the height of this object public void turnToFace(SimpleTurtle turtle)9 public void turnToFace(int x, int y)8 Method to get the information color public void turnToFace(int x, int y)9 public Picture getPicture()0 Method to get the model display for this simple turtle public Picture getPicture()1 public Picture getPicture()2 Method to get the name of the turtle public Picture getPicture()3 public Picture getPicture()4 Method to get the pen public void turnToFace(SimpleTurtle turtle)9 public Picture getPicture()6 Method to get the pen color public void turnToFace(int x, int y)5 public Picture getPicture()8 Method to get the pen width public Picture getPicture()9 public SimpleTurtle(int x, int y)00 Method to get the picture for this simple turtle public void turnToFace(SimpleTurtle turtle)9 public SimpleTurtle(int x, int y)02 Method to get the shell color public SimpleTurtle(int x, int y)03 public SimpleTurtle(int x, int y)04 Method to get value of show info public void turnToFace(int x, int y)5 public SimpleTurtle(int x, int y)06 Method to return the width of this object public void turnToFace(int x, int y)5 public SimpleTurtle(int x, int y)08 Method to get the current x position public void turnToFace(int x, int y)5 public SimpleTurtle(int x, int y)10 Method to get the current y position public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)12 Method to hide the turtle (stop showing it) This doesn't affect the pen status public SimpleTurtle(int x, int y)03 public SimpleTurtle(int x, int y)14 Method to check if the pen is down public SimpleTurtle(int x, int y)03 public SimpleTurtle(int x, int y)16 Method to get the value of the visible flag public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)18 Method to move to turtle to the given x and y location public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)20 Method to paint the turtle public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)22 Method to set the pen down public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)24 Method to lift the pen up public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)26 Method to set the body color which will also set the pen color public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)28 Method to set the color of the turtle. public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)30 Method to set the heading public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)32 Method to set the height of this object public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)34 Method to set the information color public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)36 Method to set the model display for this simple turtle public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)38 Method to set the name of the turtle public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)40 Method to set the pen public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)42 Method to set the pen color public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)44 Method to set the pen down boolean variable public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)46 Method to set the pen width public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)48 Method to set the picture for this simple turtle public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)50 Method to set the shell color public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)52 Method to show the turtle information string public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)54 Method to set the visible flag public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)56 Method to set the width of this object public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)58 Method to show the turtle (doesn't affect the pen status public Picture getPicture()1 public SimpleTurtle(int x, int y)60 Method to return a string with informaiton about this turtle public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)62 Method to turn the turtle the passed degrees use negative to turn left and pos to turn right public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)64 Method to turn left public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)66 Method to turn right public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)68 Method to turn towards the given x and y public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)70 Method to turn to face another simple turtle public double getDistance(int x, int y)5 public SimpleTurtle(int x, int y)72 Method to update the display of this turtle and also check that the turtle is in the bounds Methods inherited from class java.lang.Object public SimpleTurtle(int x, int y)73 public SimpleTurtle(int x, int y)Constructor that takes the x and y position for the turtleParameters: public SimpleTurtle(int x, int y)74 - the x pos public SimpleTurtle(int x, int y)75 - the y pos public SimpleTurtle(int x, int y, ModelDisplay display)Constructor that takes the x and y position and the model displayerParameters: public SimpleTurtle(int x, int y)74 - the x pos public SimpleTurtle(int x, int y)75 - the y pos public SimpleTurtle(int x, int y)78 - the model display public SimpleTurtle(ModelDisplay display)Constructor that takes a model display and adds a turtle in the middle of itParameters: public SimpleTurtle(int x, int y)78 - the model display public SimpleTurtle(int x, int y, Picture picture)Constructor that takes the x and y position and the picture to draw onParameters: public SimpleTurtle(int x, int y)74 - the x pos public SimpleTurtle(int x, int y)75 - the y pos public SimpleTurtle(int x, int y)82 - the picture to draw on public SimpleTurtle(Picture picture)Constructor that takes the picture to draw on and will appear in the middleParameters: public SimpleTurtle(int x, int y)82 - the picture to draw on getDistancepublic double getDistance(int x, int y)Get the distance from the passed x and y locationParameters: public SimpleTurtle(int x, int y)74 - the x location public SimpleTurtle(int x, int y)75 - the y location turnToFacepublic void turnToFace(SimpleTurtle turtle)Method to turn to face another simple turtle turnToFacepublic void turnToFace(int x, int y)Method to turn towards the given x and yParameters: public SimpleTurtle(int x, int y)74 - the x to turn towards public SimpleTurtle(int x, int y)75 - the y to turn towards getPicturepublic Picture getPicture()Method to get the picture for this simple turtleReturns:the picture for this turtle (may be null) setPicturepublic SimpleTurtle(int x, int y)0Method to set the picture for this simple turtleParameters: public SimpleTurtle(int x, int y)88 - the picture to use getModelDisplaypublic SimpleTurtle(int x, int y)1Method to get the model display for this simple turtleReturns:the model display if there is one else null setModelDisplaypublic SimpleTurtle(int x, int y)2Method to set the model display for this simple turtleParameters: public SimpleTurtle(int x, int y)89 - the model display to use getShowInfopublic SimpleTurtle(int x, int y)3Method to get value of show infoReturns:true if should show info, else false setShowInfopublic SimpleTurtle(int x, int y)4Method to show the turtle information stringParameters: public SimpleTurtle(int x, int y)90 - the value to set showInfo to getShellColorpublic SimpleTurtle(int x, int y)5Method to get the shell colorReturns:the shell color setShellColorpublic SimpleTurtle(int x, int y)6Method to set the shell colorParameters: public SimpleTurtle(int x, int y)91 - the color to use getBodyColorpublic SimpleTurtle(int x, int y)7Method to get the body colorReturns:the body color setBodyColorpublic SimpleTurtle(int x, int y)8Method to set the body color which will also set the pen colorParameters: public SimpleTurtle(int x, int y)91 - the color to use setColorpublic SimpleTurtle(int x, int y)9Method to set the color of the turtle. This will set the body colorParameters: public SimpleTurtle(int x, int y)91 - the color to use getInfoColorpublic SimpleTurtle(int x, int y, ModelDisplay display)0Method to get the information colorReturns:the color of the information string setInfoColorpublic SimpleTurtle(int x, int y, ModelDisplay display)1Method to set the information colorParameters: public SimpleTurtle(int x, int y)91 - the new color to use getWidthpublic SimpleTurtle(int x, int y, ModelDisplay display)2Method to return the width of this objectReturns:the width in pixels getHeightpublic SimpleTurtle(int x, int y, ModelDisplay display)3Method to return the height of this objectReturns:the height in pixels setWidthpublic SimpleTurtle(int x, int y, ModelDisplay display)4Method to set the width of this objectParameters: public SimpleTurtle(int x, int y)95 - in width in pixels setHeightpublic SimpleTurtle(int x, int y, ModelDisplay display)5Method to set the height of this objectParameters: public SimpleTurtle(int x, int y)96 - the height in pixels getXPospublic SimpleTurtle(int x, int y, ModelDisplay display)6Method to get the current x positionReturns:the x position (in pixels) getYPospublic SimpleTurtle(int x, int y, ModelDisplay display)7Method to get the current y positionReturns:the y position (in pixels) getPenpublic SimpleTurtle(int x, int y, ModelDisplay display)8Method to get the penReturns:the pen setPenpublic SimpleTurtle(int x, int y, ModelDisplay display)9Method to set the penParameters: public SimpleTurtle(int x, int y)97 - the new pen to use isPenDownpublic SimpleTurtle(ModelDisplay display)0Method to check if the pen is downReturns:true if down else false setPenDownpublic SimpleTurtle(ModelDisplay display)1Method to set the pen down boolean variableParameters: public SimpleTurtle(int x, int y)90 - the value to set it to penUppublic SimpleTurtle(ModelDisplay display)2Method to lift the pen up penDownpublic SimpleTurtle(ModelDisplay display)3Method to set the pen down getPenColorpublic SimpleTurtle(ModelDisplay display)4Method to get the pen colorReturns:the pen color setPenColorpublic SimpleTurtle(ModelDisplay display)5Method to set the pen colorParameters: public SimpleTurtle(int x, int y)91 - the color for the pen ink setPenWidthpublic SimpleTurtle(ModelDisplay display)6Method to set the pen widthParameters: public SimpleTurtle(int x, int y, ModelDisplay display)00 - the width to use in pixels getPenWidthpublic SimpleTurtle(ModelDisplay display)7Method to get the pen widthReturns:the width of the pen in pixels clearPathpublic SimpleTurtle(ModelDisplay display)8Method to clear the path (history of where the turtle has been) getHeadingpublic SimpleTurtle(ModelDisplay display)9Method to get the current headingReturns:the heading in degrees setHeadingpublic SimpleTurtle(int x, int y, Picture picture)0Method to set the headingParameters: public SimpleTurtle(int x, int y, ModelDisplay display)01 - the new heading to use getNamepublic SimpleTurtle(int x, int y, Picture picture)1Method to get the name of the turtleReturns:the name of this turtle setNamepublic SimpleTurtle(int x, int y, Picture picture)2Method to set the name of the turtleParameters: public SimpleTurtle(int x, int y, ModelDisplay display)02 - the new name to use isVisiblepublic SimpleTurtle(int x, int y, Picture picture)3Method to get the value of the visible flagReturns:true if visible else false hidepublic SimpleTurtle(int x, int y, Picture picture)4Method to hide the turtle (stop showing it) This doesn't affect the pen status showpublic SimpleTurtle(int x, int y, Picture picture)5Method to show the turtle (doesn't affect the pen status setVisiblepublic SimpleTurtle(int x, int y, Picture picture)6Method to set the visible flagParameters: public SimpleTurtle(int x, int y)90 - the value to set it to updateDisplaypublic SimpleTurtle(int x, int y, Picture picture)7Method to update the display of this turtle and also check that the turtle is in the bounds forwardpublic SimpleTurtle(int x, int y, Picture picture)8Method to move the turtle foward 100 pixels forwardpublic SimpleTurtle(int x, int y, Picture picture)9Method to move the turtle forward the given number of pixelsParameters: public SimpleTurtle(int x, int y, ModelDisplay display)04 - the number of pixels to walk forward in the heading direction backwardpublic SimpleTurtle(Picture picture)0Method to go backward by 100 pixels backwardpublic SimpleTurtle(Picture picture)1Method to go backward a given number of pixelsParameters: public SimpleTurtle(int x, int y, ModelDisplay display)04 - the number of pixels to walk backward moveTopublic SimpleTurtle(Picture picture)2Method to move to turtle to the given x and y locationParameters: public SimpleTurtle(int x, int y)74 - the x value to move to public SimpleTurtle(int x, int y)75 - the y value to move to turnLeftpublic SimpleTurtle(Picture picture)3Method to turn left turnRightpublic SimpleTurtle(Picture picture)4Method to turn right turnpublic SimpleTurtle(Picture picture)5Method to turn the turtle the passed degrees use negative to turn left and pos to turn rightParameters: public SimpleTurtle(int x, int y, ModelDisplay display)08 - the amount to turn in degrees droppublic SimpleTurtle(Picture picture)6Method to draw a passed picture at the current turtle location and rotation in a picture or model displayParameters: public SimpleTurtle(int x, int y, ModelDisplay display)09 - the picture to drop paintComponentpublic SimpleTurtle(Picture picture)7Method to paint the turtleParameters: public SimpleTurtle(int x, int y, ModelDisplay display)10 - the graphics context to paint on drawInfoStringpublic SimpleTurtle(Picture picture)8Method to draw the information stringParameters: public SimpleTurtle(int x, int y, ModelDisplay display)10 - the graphics context toStringpublic SimpleTurtle(Picture picture)9Method to return a string with informaiton about this turtleReturns:a string with information about this object What changes the color of the turtle arrow?color() This method is used to change the color of the turtle. The default color is black.
Which of the following turtle methods lets you change the background color of the screen?bgcolor() This method is used to set or return background color of the Turtle Screen.
What are the methods of a turtle?Overview of available Turtle and Screen methods. forward() | fd(). backward() | bk() | back(). right() | rt(). left() | lt(). goto() | setpos() | setposition(). setheading() | seth(). Which command is used to set color in shaped turtles?fillcolor(): This helps to choose the color for filling the shape. It takes the input parameter as the color name or hex value of the color and fills the upcoming closed geographical objects with the chosen color. Color names are basic color names i.e. red, blue, green, orange.
|