Glass

class Glass(val board: GameBoard, val location: GridPos)

The class Glass represents glasses in a game of Viinaharava. A glass object is mutable: it is initially full of water but can be modified to contain booze instead and can be emptied.

Value parameters:
board

the game board that the glass is located on

location

the location of the glass on the game board

class Object
trait Matchable
class Any

Value members

Concrete methods

Returns the number of neighboring booze glasses (diagonals included).

Returns the number of neighboring booze glasses (diagonals included).

Note to students: This method only returns the the glass’s danger level. It does NOT change the level; that is pourBooze’s job.

def empty(): Boolean

Empties the glass. This just means that the glass is now empty instead of full. (If the glass was already empty, this method does nothing but return false.)

Empties the glass. This just means that the glass is now empty instead of full. (If the glass was already empty, this method does nothing but return false.)

Returns:

true if the glass was full, false if it wasn’t

Determines whether the glass is a glass of booze. A glass counts as a booze glass even if the booze has already been drunk.

Determines whether the glass is a glass of booze. A glass counts as a booze glass even if the booze has already been drunk.

Determines whether the glass is empty.

Determines whether the glass is empty.

Determines whether the glass has a dangerLevel of zero.

Determines whether the glass has a dangerLevel of zero.

Returns this glass’s neighboring glasses (diagonals included) on the game board.

Returns this glass’s neighboring glasses (diagonals included) on the game board.

If the glass is a water glass (full or empty), turns it into a full booze glass. This raises the danger levels of neighboring glasses. If the glass was a booze glass (full or empty) to begin with, this method does nothing.

If the glass is a water glass (full or empty), turns it into a full booze glass. This raises the danger levels of neighboring glasses. If the glass was a booze glass (full or empty) to begin with, this method does nothing.

See also:

Concrete fields