Class Watch
java.lang.Object
it.unimi.di.prog2.h14.member.Watch
- All Implemented Interfaces:
Iterable<Watch.Gear>
A watch with gears.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List<Watch.Gear> The gears of this watch, must be non-null and not contain null.final StringThe model of this watch, must be non-empty (and not null). -
Constructor Summary
ConstructorsConstructorDescriptionWatch(String model, List<Watch.Gear> gears) Creates a watch with the given model and gears. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
model
The model of this watch, must be non-empty (and not null). -
gears
The gears of this watch, must be non-null and not contain null.
-
-
Constructor Details
-
Watch
Creates a watch with the given model and gears.- Parameters:
model- the model of the watch.gears- the gears of the watch.- Throws:
IllegalArgumentException- if model is empty.NullPointerException- if model or gears is null or if gears contains null.
-
-
Method Details
-
tick
public void tick()Simulates a tick of this watch, increasing the number of rotations of all its gears by one. -
iterator
- Specified by:
iteratorin interfaceIterable<Watch.Gear>
-
toString
-