All pastes #198144 Raw Edit

Mine

public text v1 · immutable
#198144 ·published 2006-10-11 20:04 UTC
rendered paste body
import se.lth.cs.window.SimpleWindow;

class Turtle{
	
	private int yHome,xHome;
	private double vinkel;
	private SimpleWindow w;
	private boolean pen= false;
	
	public Turtle(SimpleWindow w, int xHome, int yHome){
		
		this.xHome=xHome;
		this.yHome=yHome;
		this.w=w;
		vinkel=Math.PI/2;
	}
	
	public void penDown(){
		pen=true;
	}
	
	public void penUp(){
		pen=false;
	}
	
	 public void forward(int n){
                w.moveTo(xHome,yHome);
                
                xHome=(int) Math.round(xHome + (n*Math.cos(vinkel)));
                yHome=(int) Math.round(yHome - (n*Math.sin(vinkel)));
                if(pen){
                        w.lineTo(xHome,yHome);
                }
        		
	}
	
	public void left(int beta){
		double temp= Math.toRadians(beta);
		vinkel+=temp;
	}
	
	public void right(int beta){
		double temp2= Math.toRadians(beta);
		vinkel-=temp2;
	}
	
	public void jumpTo(int newX, int newY){
		
		xHome=newX; 
		yHome=newY;
		w.moveTo(newX, newY);
		
	}
	
	
	public void turnNorth(){
		vinkel=Math.PI/2;
	}
	
	public int getX(){
	return xHome;
	}
	
	public int getY(){
	return yHome;
	}	
		
}