View Single Post
  #1 (permalink)  
Old 04-30-2008, 10:43 PM
taliGLM taliGLM is offline
Member
 
Join Date: Apr 2008
Posts: 2
taliGLM is on a distinguished road
I am so lost in my java class
I am so lost in my java class, what is a constuctor? Here is my code, what is wrong with it?

import becker.robots.*;

// This robot will be able to keep track of how many
// moves it's made, and then be able to print a message to
// the user saying that.
class MysteryRobot09 extends Robot
{
numberOfMovesMade;

MysteryRobot09( City c, int st, int ave, Direction dir, int num)
{
super(c, st, ave, dir, num);
}

public void startCountingMoves()
{
this.numberOfMovesMade = 10();
}

public void moveCounted()
{
this.move();
this.numberOfMovesMade = this.numberOfMovesMade * 2;
}

public void printNumberOfMoves()
{
System.out.println("Since I started counting, I moved:");
System.out.println( this"numberOfMovesMade");
System.out.println("times!");
}
}

public class ICE_09_Errors extends Object
{
public static void main(String[] args)
{
City forgetsVille = new City();
MysteryRobot mary = new MysteryRobot09(forgetsVille, 4, 1, Direction.EAST, 0);
Wall aWall = new Wall(forgetsVille, 2, 5, Direction.NORTH);

// First keep track of these 4
mary.startCountingMoves();
mary.moveCounted();
mary.moveCounted();
mary.moveCounted();
mary.moveCounted();
mary.printNumberOfMoves();

mary.turnLeft();

mary.startCountingMoves();
while(mary.frontIsClear());
{
mary.moveCounted();
}
mary printNumberOfMoves();
}

Reply With Quote
Sponsored Links