Home | Trees | Indices | Help |
|
---|
|
object --+ | SleepingCar
The class SleepingCar
represents the sleeping cars of a
train in a train ticket reservation system. Each sleeping car is divided
in cabins which have SleepingCar.BEDS_PER_CABIN
places
(beds) for passengers. The cabins are numbered from one upwards.
This implementation works in such a way that whenever anyone reserves any places in the car, at least one full cabin is reserved.
In this simple model, no data is stored about who has reserved which places (beds) in the cars. Cars will only know if places are reserved or not.
|
|||
|
|||
int |
|
||
float |
|
||
int |
|
||
int |
|
||
int |
|
||
boolean |
|
||
boolean |
|
||
boolean |
|
||
int |
|
||
int |
|
||
Inherited from |
|
|||
BEDS_PER_CABIN = 3
|
|
|||
Inherited from |
|
Creates a new sleeping car with the given number of cabins.
|
Tells how many places (beds) this car has for passengers.
|
Tells how many percent of the car's passenger places have been reserved.
|
Tells how many free (unreserved) places (beds) this car has for passengers.
|
Tells how many cabins there are in this car.
|
Tells how many free (unreserved) places (beds) there are in the indicated cabin.
|
Tells if the indicated cabin is empty. That is, tells whether none of its beds have been reserved or not.
|
Reserves all the places (beds) in one cabin. If the cabin was not
originally empty, this method does nothing but return
|
Reserves places (beds) for a group. For a sleeping car, a group reservation means that whole (originally empty) cabins are reserved so that all the members of the group fit in them. E.g. if the group size is 7, and each cabin has three beds, three cabins will be reserved. The cabins to be reserved are selected simply so that the smallest possible empty cabin numbers are determined, and those cabins are reserved. The cabins need not be adjacent to each other. If it is not possible to reserve suitable places for all members of the group, no places are reserved at all.
|
Returns the number of empty cabins in the car.
|
Searches for the first empty cabin in the car.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Aug 30 16:13:47 2012 | http://epydoc.sourceforge.net |