o1.train.SleepingCar
See theSleepingCar companion object
class SleepingCar(val
numberOfCabins
: Int) extends TrainCar
The class SleepingCar
represents sleeping cars in a train ticket reservation system. Each sleeping car is divided in equal-sized cabins which have a set number of places (beds) for passengers. The cabins are numbered from one upwards.
When created, all the cabins in a sleeping car are unreserved. This changes as reservations are made.
This implementation is intended to work in such a way that whenever anyone reserves any places in the car, at least one full cabin is reserved. Multiple reservations can never share a cabin.
In this simple implementation, no data is stored about who has reserved which cabins.
Parameters
- numberOfCabins
-
the number of cabins in this sleeping car
Attributes
- See also
- Companion
- object
- Supertypes
Members list
Inherited
Not inherited +1
- Not inherited
- TrainCar