You are on page 1of 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.)

(continue to see Penguin Instantiation)

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

II) Compass Directions


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

Map

IV) Relative Directions


a. ahead
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
a. waddle()
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

isSafe(ahead)

Reflecting Cube

True

Effect of Penguin waddling


into object

Penguin is flipped around by 180

You must use isCube(ahead) to detect a


cube
Rock
False
Penguin disabled
You may use isRock(ahead) or
isSafe(ahead) to detect a rock

Water
False

Penguin disabled
You may use isWater(ahead) or
isSafe(ahead) to detect water.

Fish
True

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

Penguin
True

Nothing
You must use isPenguin(ahead) to
detect a penguin

Wall
False

Penguin disabled

You may use isSafe(ahead) or


isWall(ahead) to detect an icewall