Experience

o1.goodstuff.Experience
class Experience(val name: String, val description: String, val price: Double, val rating: Int)

The class Experience represents entries in a user’s experience diary. Each entry represents an experience as evaluated by the diarist.

An experience object is immutable once created; there are no methods to change any of its attributes.

Parameters

description

the diarist’s description of the experience, such as "Nice but unremarkable"

name

a name that identifies the experience, such as "Hotel Anna, Helsinki" or "Sangre de Toro 2007"

price

the price (per unit) in euros

rating

a rating given by the diarist to the experience (from 1 to 10 or on some other scale)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Compares two experiences — this one and the one given as a parameter — and returns the one with the higher rating. If both have the same rating, arbitrarily returns one of the two.

Compares two experiences — this one and the one given as a parameter — and returns the one with the higher rating. If both have the same rating, arbitrarily returns one of the two.

Attributes

Returns true if the experience has a higher rating than the experience given as a parameter, and false otherwise.

Returns true if the experience has a higher rating than the experience given as a parameter, and false otherwise.

Attributes

Returns the “value for money” for the experience. Value for money equals the experience’s rating divided by its price.

Returns the “value for money” for the experience. Value for money equals the experience’s rating divided by its price.

Attributes

Concrete fields

val name: String
val price: Double
val rating: Int