|
 |
|
Dev Hardware Forums
> SOFTWARE
> Programming
|
Java - DrJava
Discuss DrJava in the Programming forum on Dev Hardware. DrJava Programming forum discussing administration and coding scripts in languages including PHP, C++, C, Perl, Java, Visual Basic, XML, HTML, CGI, ActionScript, CSS, JavaScript, Fortran, BASH, and issues related to databases and even batch files.
|
|
 |
|
|
|
|

Dev Hardware Forums Sponsor:
|
|
|

February 13th, 2013, 08:19 AM
|
|
n00b DevH'er
|
|
Join Date: Feb 2013
Posts: 1
Time spent in forums: 16 m 7 sec
Reputation Power: 0
|
|
|
Java - DrJava
Hi, I'm new to Dr.Java and I'm not sure how to work it. I'm trying to finish UPenn's better bot assignment. I'm suppose to build of the bot code but I'm not sure how to even start.
Here is the code:
/**
* A BetterBot extends Bot to make a better Bot.
* @author UPenn CIS BotWorld
* @version 2009 Jan 23
*/
public class BetterBot extends Bot{
/**
* Constructs a new BetterBot in the given world.
* @param world the world in which the bot should reside
*/
public BetterBot(BotWorld world){
/**
* This line takes the current object and initializes it
* as a Bot. We'll explain exactly how this works later
* in the course.
*/
super(world);
}
/**
* Moves the bot "backward" one space, but should end up facing
* the same direction as it started.
* If the bot cannot move backward, it should return false and
* remain in its original location facing its original direction.
* @return whether the backup was successful
*/
public boolean backup(){
bot.turnLeft();
bot.turnLeft();
}
/**
* Turns around while staying in the same location.
* @return the direction the bot ends up facing
*/
public char turnAround(){
return 'n'; // REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Moves and tries to eat.
* Assumes that the bot can move forward one space.
* Moves forward one space and then tries to eat a dot.
* Returns whether it ate a dot.
* @return whether the bot ate a dot from the new location
*/
public boolean moveAndEat(){
return false; // REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Spins the bot 360 degrees in either direction while staying in the same location.
*/
public void spin360(){
// REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Eats a dot from the current location, moves
* forward one space, and puts the dot in the
* new location. Assume this is possible.
*/
public void grabAndDrop(){
// REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Moves in a 2x2 square using right turns, starting by moving
* in its current direction, and ending up in its starting cell,
* facing its original direction. Assume this is possible.
* Examples: a bot at (0,0) facing east
* should go to (1,0) then (1,1), then (0,1), then back to (0,0)
* facing east; a bot at (1,1) facing west should go to (0,1) then
* (0,0) then (1,0) then (1,1) facing west.
*/
public void squareDance(){
// REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Turns the bot so that it ends up facing south.
*/
public void faceSouth(){
// REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Returns whether the cell directly in front
* of the bot is a wall. This method should
* use the world's isWall method.
* @return whether the cell directly in front
* of the bot is a wall
*/
public boolean isFacingWall(){
return false; // REPLACE THIS LINE WITH YOUR SOLUTION
}
/**
* Using at least two of the BetterBot methods you
* just wrote, do something crazy!
*/
public void fancyDance(){
// REPLACE THIS LINE WITH YOUR SOLUTION
}
|

February 15th, 2013, 10:22 PM
|
 |
Contributing User
|
|
Join Date: Jan 2008
Location: Lilyfield NSW Australia
|
|
|
Looks like a school project / assignment. We cannot answer your assignments for you.
__________________
|
Developer Shed Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|