class Train extends AnyRef
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.
- Alphabetic
- By Inheritance
- Train
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Train(description: String)
- description
a description of the train, e.g. "From Helsinki to Oulu, leaves at 8:13"
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
- def addCar(car: TrainCar): Boolean
Adds the given car to the end of the train, if possible.
Adds the given car to the end of the train, if possible.
- car
the car to be added
- returns
true
if the car was added,false
if the length would have become excessive
- See also
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def car(numberOfCar: Int): Option[TrainCar]
Returns the car indicated by the given number, wrapped in an
Option
.Returns the car indicated by the given number, wrapped in an
Option
. ReturnsNone
if the given number is too low or too high.- numberOfCar
the number of the car that should be returned (must be between 1 and the number of cars in the train or the result will be None)
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- val description: String
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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 length: Int
Returns the number of (passenger) cars there are in this train.
- 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()
- 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.