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.
- Alphabetic
- By Inheritance
- SittingCar
- TrainCar
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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)
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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
- SittingCar → TrainCar
- 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
- SittingCar → TrainCar
- val numberOfRows: Int
- 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 returnstrue
otherwise.- numberOfRow
a row number (valid number that is >=1)
- seat
a seat identifier (valid small letter, from 'a' onwards)
- 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
- SittingCar → TrainCar
- val seatsPerRow: Int
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- 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.