Packages

c

o1.train

SittingCar

class SittingCar extends TrainCar

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.

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

Instance Constructors

  1. new SittingCar(numberOfRows: Int, seatsPerRow: Int)

    numberOfRows

    the number of seat rows in the car

    seatsPerRow

    the number of seats in each row

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. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. 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
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. def isReservedSeat(numberOfRow: Int, seat: Char): Boolean

    Returns a boolean value indicating whether the indicated seat is reserved or not.

    Returns a boolean value indicating whether the indicated seat is reserved or not.

    numberOfRow

    a row number (valid number that is >=1)

    seat

    a seat identifier (valid small letter, from 'a' onwards)

  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. def numberOfFreePlaces: Int

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

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

    Definition Classes
    SittingCarTrainCar
  17. def numberOfPlaces: Int

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

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

    Definition Classes
    SittingCarTrainCar
  18. val numberOfRows: Int
  19. def reservePlace(numberOfRow: Int, seat: Char): Boolean

    Reserves the indicated seat, if possible.

    Reserves the indicated seat, if possible. The reservation is unsuccessful if the seat was already reserved. In the latter case, the method returns false; it returns true otherwise.

    numberOfRow

    a row number (valid number that is >=1)

    seat

    a seat identifier (valid small letter, from 'a' onwards)

  20. def reservePlaces(numberOfPeople: Int): Boolean

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

    Reserves places (seats) for a group of people whose size is indicated by the parameter. For a sitting car, a group reservation means that the whole group must get adjacent seats in the same row.

    Where it would be possible to make the reservation in many different ways, the smallest possible row number and first (alphabetically) possible seat identifiers are selected.

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

    Definition Classes
    SittingCarTrainCar
  21. val seatsPerRow: Int
  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def toString: String
    Definition Classes
    AnyRef → Any
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  26. 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