Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2008, 10:43 PM
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();
}

Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-30-2008, 11:02 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
what is a constuctor?
Special method with no return type and same name as enclosing class.
See Providing Constructors for Your Classes for more.
Code:
// Type must match: // declaration type == constructor type MysteryRobot09 mary = new MysteryRobot09(forgetsVille, 4, 1, Direction.EAST, 0); MysteryRobot09( City c, int st, int ave, Direction dir, int num) { // This sends these arguments to the superclass Robot // which will keep them. super(c, st, ave, dir, num); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost my javadocs orchid Eclipse 3 04-30-2008 10:45 PM
need help with program im lost lifeturn JCreator 0 02-13-2008 12:54 AM
A little lost with for loops and making a design LinxuS New To Java 5 01-22-2008 10:05 AM
Absolutely Lost Lehane_9 New To Java 2 12-03-2007 07:25 PM
Help Needed - I'm so lost adlb1300 New To Java 3 11-14-2007 02:54 AM


All times are GMT +3. The time now is 11:56 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org