import greenfoot.*;
/**
* A Rover is a drone that likes is programmed with a generic algorithm to find and collect space tomatoes.
* The programming can be updated remotely to improve the collection algorithm for whatever planet the rovers are deployed to.
*
* @author (your name here)
* @version 0.2
*/
public class Rover extends Bot
{
// Remember: you cannot extend the Rover's memory. So:
// no additional fields (other than final fields) allowed in this class!
/**
* Default constructor for testing purposes.
*/
public Rover()
{
this(null);
}
/**
* Create a Rover with its home space ship.
*/
public Rover(Ship ship)
{
super(ship);
}
/**
* Do what a rover does.
* Most of your coding will take place in this method. You can create additional methods if needed, but you can't change any other methods.
* (apart from modifying one line in getAuthorName() below)
*/
public void act()
{
{
{
super.act(); // do not delete! leave as first statement in act().
if (carryingTomato()) {
if (atShip()) {
dropTomato();
}
if (carryingTomato()) {
if (atWater()){
turn(90);
move(2);
}
else {
turnHome();
move();
}
while(rover!= end_point)
if(roverhits_water);
turn (90);
{
while(rover!=end_point)
if(roverhits_water)
turn (90);
}
}
}
}
}
/**
* Is there any food here where we are? If so, try to load some!
*/
{
Public_void (checkFood);
{
{
// check whether there's a tomato pile here
TomatoPile tomatoes = (TomatoPile) getOneIntersectingObject(TomatoPile.class);
if (tomatoes != null) {
loadTomato();
if (carryingTomato()) {
turnHome();
turnHome();
move();
}
// Note: this attempts to load a tomato onto *another* Rover. It won't
// do anything if we are alone here.
}
}
/**
* This method specifies the name of the author (for display on the result board).
*/
Public_static String_getAuthorName;
{
return "Anonymous"; //ENTERNAMEHERE
}
{
/**
* This method specifies the image we want displayed at any time. (No need
* to change this for the competition.)
*/
Public_String_getCurrentImage();
{
if (carryingTomato()) {
return "rover-with-food.gif";
}
else {
return "rover.gif";
}
}
}import greenfoot.*;
/**
* A Rover is a drone that likes is programmed with a generic algorithm to find and collect space tomatoes.
* The programming can be updated remotely to improve the collection algorithm for whatever planet the rovers are deployed to.
*
* @author (your name here)
* @version 0.2
*/
public class Rover extends Bot
{
// Remember: you cannot extend the Rover's memory. So:
// no additional fields (other than final fields) allowed in this class!
/**
* Default constructor for testing purposes.
*/
public Rover()
{
this(null);
}
/**
* Create a Rover with its home space ship.
*/
public Rover(Ship ship)
{
super(ship);
}
/**
* Do what a rover does.
* Most of your coding will take place in this method. You can create additional methods if needed, but you can't change any other methods.
* (apart from modifying one line in getAuthorName() below)
*/
public void act()
{
super.act(); // do not delete! leave as first statement in act().
if (carryingTomato())
{
if (atShip())
{
dropTomato();
}
if (carryingTomato())
{
if (atWater())
{
turn(90);
move(2);
}
else
{
turnHome();
move();
}
while(rover!= end_point) if(roverhits_water) ;
turn (90);
{
while(rover!=end_point) if(roverhits_water) turn (90);
}
}
}
}
/**
* Is there any food here where we are? If so, try to load some!
*/
public void checkFood()
{
// check whether there's a tomato pile here
TomatoPile tomatoes = (TomatoPile) getOneIntersectingObject(TomatoPile.class);
if (tomatoes != null)
{
loadTomato();
if (carryingTomato())
{
turnHome();
turnHome();
move();
}
// Note: this attempts to load a tomato onto *another* Rover. It won't
// do anything if we are alone here.
}
}
/**
* This method specifies the name of the author (for display on the result board).
*/
public static String getAuthorName;
{
return "Anonymous"; //ENTERNAMEHERE
}
/**
* This method specifies the image we want displayed at any time. (No need
* to change this for the competition.)
*/
public String getCurrentImage();
{
if (carryingTomato())
{
return "rover-with-food.gif";
}
else
{
return "rover.gif";
}
}
}