Represent a Berlin Clock within a JVM language
$ ./gradlew assemble
# Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
# :compileJava
# :processResources NO-SOURCE
# :classes
# :jar
# :assemble
# BUILD SUCCESSFUL
$ ./gradlew test
# :compileJava UP-TO-DATE
# :processResources NO-SOURCE
# :classes UP-TO-DATE
# :compileTestJava
# :processTestResources NO-SOURCE
# :testClasses
# :test
# :jacocoTestReport
# BUILD SUCCESSFUL
# Total time: 2.284 secs
These get generated in the following path ./build/reports/jacoco/test
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
BerlinClock clock = new BerlinClock(10, 31, 0);
System.out.println(clock); // Outputs the following
// Y
// RRXX
// XXXX
// YYRYYRXXXXX
// YXXX
// Make the clock go forward five minutes
IntStream.range(0, 60 * 5).forEach(i -> clock.tick());
System.out.println(clock); // Outputs the following
// Y
// RRXX
// XXXX
// YYRYYRYXXXX
// YXXX
}
}
- Diego Camargo