Skip to content

raffaeleflorio/oo-boggle

Repository files navigation

Object oriented boggle game with HTTP interface

Licensed under Apache-2.0 CircleCI build status Codecov reports Hits-of-Code Swagger UI

A reactive object oriented implementation of the Boggle game with a HTTP interface. The latter is implemented with Vert.x.

It's written with minimalism, flexibility and object thinking in mind. Indeed, the main just composes bigger objects from smaller ones:

public final class Main {
  public static void main(String[] args) {
    var vertx = Vertx.vertx();
    vertx.deployVerticleAndAwait(
      new HttpInfrastructure(
        new DurationMatches<>(
          new DeadlineMatches<>(
            new ClassicRuledMatches<>(
              new InMemoryMatches<>(
                new MappedGrids<>(
                  new InMemoryGrids<>(
                    Map.of(
                      new FeatureEqualityPredicate(
                        Map.of(
                          "lang", List.of("it"),
                          "size", List.of("4x4")
                        )
                      ),
                      new LangGrid<>(
                        new FourByFourGrid<>(new SixteenItalianDice()), "it"
                      )
                    )
                  ),
                  LayoutGrid::new
                )
              ),
              Map.of(
                new FeatureEqualityPredicate(
                  Map.of(
                    "lang", List.of("it"),
                    "size", List.of("4x4")
                  )
                ),
                match -> new IfInGrid<>(
                  new IfInVocabulary<>(
                    new FourByFourScore<>(),
                    new DizionarioItalianoIt(WebClient.create(vertx))
                  ),
                  match.grid()
                )
              )
            )
          ),
          Duration::ofMinutes
        ),
        parseUnsignedInt(args[0]),
        args[1]
      )
    );
  }
}

How to run

You should first build the uber jar, then you can run it with java. Port and interface are mandatory. For example to run on the 127.0.0.1 interface on the 8080 port:

$ ./mvnw clean package
$ java -jar target/boggle-1.0.0-SNAPSHOT.jar 8080 127.0.0.1

Javadoc

The project is documented through javadoc. To generate it in target/site/apidocs:

$ ./mvnw clean javadoc:javadoc

Code coverage report

The project is covered by tests. To generate code coverage report in target/site/jacoco:

$ ./mvnw clean test jacoco:report