package train
- Alphabetic
- Public
- Protected
Type Members
- class SittingCar extends TrainCar
The class
SittingCar
represents passenger cars with seats in a train ticket reservation system.The class
SittingCar
represents passenger cars with seats in a train ticket reservation system. Each sitting car has rows of seats, which are numbered starting from one upwards. Each row has a number of seats, identified by letters starting from 'a'.When created, all the seats in a sitting car are unreserved; this changes as reservations are made.
In this simple implementation, no data is stored about who has reserved which seat.
- class SleepingCar extends TrainCar
The class
SleepingCar
represents sleeping cars in a train ticket reservation system.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.
- See also
- class Train extends AnyRef
The class
Train
represents trains which consist of a number of passenger cars.The class
Train
represents trains which consist of a number of passenger cars. The cars are numbered from one upwards (starting from the head of the train).A train object is mutable. New cars can be added to it with the
addCar
method, but initially a train has no cars. Trains have a maximum length (in cars) which they must not exceed.A train may contain cars of various types, that is, instances of any class that mixes in the
TrainCar
trait. - trait TrainCar extends AnyRef
This trait represents the passenger cars of a train in a train ticket reservation system.
This trait represents the passenger cars of a train in a train ticket reservation system. It describes the common operations of all passenger car types. Different classes representing different kinds of train cars will have different implementations for these operations.
In this simple implementation, no data is stored about who has reserved which places (seats, beds, or the like) in the cars. A car object only keeps track of whether a place is reserved or not.
A train car's state is mutable; it changes as reservations are made.
Value Members
- object SleepingCar
This companion object of the
SleepingCar
class merely provides a named constant that the class uses.This companion object of the
SleepingCar
class merely provides a named constant that the class uses.- See also
the class SleepingCar
- object Train
This companion object of the
Train
class merely provides a named constant that the class uses.This companion object of the
Train
class merely provides a named constant that the class uses.- See also
the class Train