Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a project in CIS and im struggling with it. These are the instructions vi

ID: 3758342 • Letter: I

Question

I have a project in CIS and im struggling with it. These are the instructions via Image. Im not sure how to go about doing it. The Language used is through GREENFOOT(Java) and you are supposed to design a game:

Part 1:

GreenFoot book PDF for Part 1:

http://medziaga.puslapiai.lt/Introduction_To_Programming_With_Greenfoot.pdf

Part 2:

GreenFoot book PDF for Part 2:

http://medziaga.puslapiai.lt/Introduction_To_Programming_With_Greenfoot.pdf

Greenfoot image of little Crab for Part2:

Crab_World code:

import greenfoot.*; // (Actor, World, Greenfoot, GreenfootImage)

public class CrabWorld extends World
{
/**
* Create the crab world (the beach). Our world has a size
* of 560x560 cells, where every cell is just 1 pixel.
*/
public CrabWorld()
{
super(560, 560, 1);
}
}

Animal code:

import greenfoot.*;

import java.util.List;
import java.util.ArrayList;

/**
* Animal. This is the base class for all animals. In addition to the standard Actor
* methods, it provides the ability to move and turn.
*
* @author Michael Kolling
* @version 1.0
*/
public class Animal extends Actor
{
private static final double WALKING_SPEED = 5.0;
  
/**
* Constructor for Animal - nothing to do.
*/
public Animal()
{
}

/**
* Act - empty method. Animals have no default action.
*/
public void act()
{
}
  
  
/**
* Turn 'angle' degrees towards the right (clockwise).
*/
public void turn(int angle)
{
setRotation(getRotation() + angle);
}
  

/**
* Move forward in the current direction.
*/
public void move()
{
double angle = Math.toRadians( getRotation() );
int x = (int) Math.round(getX() + Math.cos(angle) * WALKING_SPEED);
int y = (int) Math.round(getY() + Math.sin(angle) * WALKING_SPEED);
  
setLocation(x, y);
}

  
/**
* Test if we are close to one of the edges of the world. Return true is we are.
*/
public boolean atWorldEdge()
{
if(getX() < 20 || getX() > getWorld().getWidth() - 20)
return true;
if(getY() < 20 || getY() > getWorld().getHeight() - 20)
return true;
else
return false;
}
  
  
/**
* Return true if we can see an object of class 'clss' right where we are.
* False if there is no such object here.
*/
public boolean canSee(Class clss)
{
Actor actor = getOneObjectAtOffset(0, 0, clss);
return actor != null;
}

  
/**
* Try to eat an object of class 'clss'. This is only successful if there
* is such an object where we currently are. Otherwise this method does
* nothing.
*/
public void eat(Class clss)
{
Actor actor = getOneObjectAtOffset(0, 0, clss);
if(actor != null) {
getWorld().removeObject(actor);
}
}
}

Crab Code:

import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)

/**
* This class defines a crab. Crabs live on the beach.
*/
public class Crab extends Animal
{
public void act()
{
if (atWorldEdge()) {
turn(17);
}
move();
}
}

Part 3:

Grading Scale:

Thank you for your help in Advance!

Explanation / Answer

CODE :

// crabworld

// crab

// lobster