Class ShipPiece

java.lang.Object
greenfoot.Actor
student.micro.Actor
student.micro.battleship.ShipPiece

public class ShipPiece extends student.micro.Actor
Represents a ship piece in the game "Battleship", so it can be shown on the screen.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ShipPiece(ShipType type, int x, int y, boolean orientedHorizontally)
    Create a new Ship piece.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addedToWorld(greenfoot.World world)
     

    Methods inherited from class student.micro.Actor

    addToWorld, getIntersectingObjects, getNeighbors, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneNeighbor, getOneNeighbour, getOneObjectAtOffset, getOneObjectInRange, remove, turnTowards

    Methods inherited from class greenfoot.Actor

    act, getImage, getRotation, getWorld, getWorldOfType, getX, getY, isAtEdge, move, setImage, setImage, setLocation, setRotation, turn, turnTowards

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ShipPiece

      public ShipPiece(ShipType type, int x, int y, boolean orientedHorizontally)
      Create a new Ship piece.
      Parameters:
      type - The type of ship in your fleet that this piece represents.
      x - The x-coordinate of the position for the ship's bow (its upper-leftmost location on the grid).
      y - The y-coordinate of the position for the ship's bow (its upper-leftmost location on the grid).
      orientedHorizontally - If true, the ship extends horizontally to the right of the specified position. If false, the ship extends vertically down from the specified position.
  • Method Details

    • addedToWorld

      public void addedToWorld(greenfoot.World world)