Anda di halaman 1dari 7

# Overview of most common objects and methods needed for keeping your penguin in good health (ie

not running into walls or other things that don't have a good effect on your penguin)
Contents
I)
II)
III)
IV)
V)
VI)

Penjee's World
Penguin Instantiation
Relative Directions
Compass Directions
Action Methods
Boolean Methods (with some gotchas, at least read this one over once)

I) Penjee's World
Penguins, fish, and other objects exist inside an ice world. The borders of this world are "walls"
of ice. If your Penguin tries to move outside the map, the penguin will hit the ice wall and become
disabled. So, be kind to your Penguin and don't hit the outer walls! (We'll show you all sorts of neat tricks
later on how to do this like a programmer.)

## II) Penguin Instantiation

A. Penguin()
The default constructor places a Penguin in row 0, column 0, facing east, with 0 fish and looks
something like:
Code

Map

B. Penguin(compass_direction)
Passing a single compass direction will instantiate a penguin at row 0, column 0, facing in
compass_direction, with 0 fish
Example Code

Map

C. Penguin(num_fish)
Passing a single integer will instantiate a penguin at row 0, column 0, facing East, with num_fish
fish
Example Code

Map

## D. Penguin( _row , _col)

Passing two integers will instantiate a penguin at row _row, column _col , facing East, with 0 fish.
Example Code

Map

## E. Penguin( _row , _col, num_fish)

Passing three integers will instantiate a penguin at row _row, column _col , facing East, with num_fish
fish
Example Code

Map

## F. Penguin( _row , _col, num_fish)

Passing three integers will instantiate a penguin at row _row, column _col , facing East, with num_fish
fish.
Example Code

a. east
b. west
c. north
d. south

Map

## IV) Relative Directions

b. left
c. right
d. here
Warning. By relative, we mean that left is based on the penguin's current compass direction.

V) Action Methods
Penguin attempts to move the penguin forward one position.
b. grab()
Penguin picks up a fish-- if the penguin is on top of a fish. Note: Calling grab() on an
empty cell (ie one without a fish) has no effect.
c. drop()
Penguin drops a fish onto its current cell.
d. giveFish()
Penguin transfers a fish to a second penguin.

## Boolean methods on next page

IV)Boolean Methods
A.
B.
C.
D.
E.

isWater(relative_direction)
isWall(relative_direction)
isRock(relative_direction)
isSafe(relative_direction)
hasFish() #coming soon..to Penjee 2.0 due out in late fall of 2016

Continued

Object

Reflecting Cube

True

into object

## You must use isCube(ahead) to detect a

cube
Rock
False
Penguin disabled

Water
False

Penguin disabled

Fish
True

Nothing
isFish(here) to detect a fish
NOTE: it's possible for multiple fish to be
in one cell

Penguin
True

Nothing