Glass

o1.viinaharava.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.

Parameters

board

the game board that the glass is located on

location

the location of the glass on the game board

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

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.

Attributes

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.)

Attributes

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.

Attributes

Determines whether the glass is empty.

Determines whether the glass is empty.

Attributes

Determines whether the glass has a dangerLevel of zero.

Determines whether the glass has a dangerLevel of zero.

Attributes

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

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

Attributes

def pourBooze(): Unit

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.

Attributes

See also

Concrete fields