These methods return either true or false.
penjee.isWater(relativeDirection)
Is water in the indicted direction?
penjee.isSafe(relativeDirection)
Are there no obstracles (water, wall, Penguin) in the indicated direction?
p.isFish(relativeDirection)
Is a fish in the indicted direction?
Same thing for all boolean methods, i.e.: p.isFish(left)
The commands below control Penguin movements and how they interact with fish.
giveFish()
ex: penjee = Penguin()
penjee.giveFish()
Move forward one space
ex: penjee = Penguin()
penjee.waddle()
Move forward n space
ex: penjee = Penguin()
penjee.waddle(2)
Turn left
ex: penjee = Penguin()
penjee.turnLeft()
Turn right
ex: penjee = Penguin()
penjee.turnRight()
Grab fish from the current location
ex: penjee = Penguin()
penjee.grab()
There are several ways to make a Penguin. All Penguins start in a row and column, facing some direction and with a certain number of fish.
pam = Penguin()
What this does: it puts a Penguin in the row zero, column zero (top left corner), facing east and with zero fish , like this picture:
tim = Penguin(someRow,someCol)
What this does: it puts a Penguin in the row ‘someRow, column ‘someCol’, facing east and with zero fish .
Code: Penguin(0,2) puts a penguin in row zero and column 2 like this picture:
jennifer = Penguin(someDirection)
What this does: it puts a Penguin in the row zero, column zero (top left corner), facing ‘someDirection’ and with zero fish .
Code: Penguin(south) puts a penguin in row zero and column zero , facing south:
kim = Penguin(someRow, someCol, someDirection, numFish)
What this does: it puts a Penguin in the row ‘someRow’, column ‘someCol’ , facing ‘someDirection’ and with ‘numFish’ amount of fish
Code: Penguin(1,4, north, 7 ) puts a penguin in row 1 , column 4 , facing north and with 7 penguin: