Packages

class SleepingCar 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.

See also

SleepingCar.BedsPerCabin

Linear Supertypes
TrainCar, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SleepingCar
  2. TrainCar
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new SleepingCar(numberOfCabins: Int)

    numberOfCabins

    the number of cabins in this sleeping car

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  6. def emptyCabinCount: Int

    Returns the number of empty cabins in the car.

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def fullness: Double

    Returns a figure between 0 and 100 that indicates how many percent of the car's passenger places have been reserved.

    Returns a figure between 0 and 100 that indicates how many percent of the car's passenger places have been reserved.

    Definition Classes
    TrainCar
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  12. def isEmptyCabin(cabinNumber: Int): Boolean

    Determines if the indicated cabin is empty, that is, whether none of its beds have been reserved or not.

    Determines if the indicated cabin is empty, that is, whether none of its beds have been reserved or not.

    cabinNumber

    a cabin number (>=1 and no bigger than the number of cabins)

  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. val numberOfCabins: Int
  18. def numberOfFreeBedsInCabin(cabinNumber: Int): Int

    Returns the number of free (unreserved) places (beds) there are in the given cabin.

    Returns the number of free (unreserved) places (beds) there are in the given cabin.

    cabinNumber

    a cabin number (>=1 and no bigger than the number of cabins)

  19. def numberOfFreePlaces: Int

    Returns the number of free, unreserved places (beds) in this car.

    Returns the number of free, unreserved places (beds) in this car.

    Definition Classes
    SleepingCarTrainCar
  20. def numberOfPlaces: Int

    Returns the number of places (beds) this car has for passengers.

    Returns the number of places (beds) this car has for passengers. This is a positive number.

    Definition Classes
    SleepingCarTrainCar
  21. def reserveCabin(cabinNumber: Int): Boolean

    Reserves all the places (beds) in one cabin.

    Reserves all the places (beds) in one cabin. Returns a boolean value indicating whether the reservation was successful. If the cabin was not originally empty, this method does nothing but return false.

    cabinNumber

    a cabin number (>=1 and no bigger than the number of cabins)

  22. def reservePlaces(numberOfPeople: Int): Boolean

    Reserves places (beds) for a group of people whose size is indicated by the parameter.

    Reserves places (beds) for a group of people whose size is indicated by the parameter. For a sleeping car, a group reservation means that a number of entire empty cabins is reserved so that all the members of the group fit in them. For instance, if the group size is seven, and each cabin has three beds, three whole cabins will be reserved.

    The cabins to be reserved are selected simply so that the smallest available numbers of empty cabins are determined, and those cabins are reserved. The cabins need not be adjacent to each other, but must all be in this car.

    If it is not possible to reserve suitable cabins for all members of the group, no places are reserved at all. The return value of this method indicates whether the places were reserved or not.

    Definition Classes
    SleepingCarTrainCar
  23. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  24. def toString: String
    Definition Classes
    AnyRef → Any
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from TrainCar

Inherited from AnyRef

Inherited from Any

Ungrouped