Writing implementation of first class in Java

Setting up project

You can find some template repository for java projects with Gradle can be found here. You can also generate new project template using your favourite IDE as we did on our last meeting.

We’ve seen some basic Gradle tasks that you can run to work with project.

Gradle tasks

  1. Test task
    ./gradlew test
    

    runs test classes from your project. The classes that contain methods with @Test annotation are the definitions of unit tests for your classes - they’ll be executed for this task.

  2. Package app task
    ./gradlew shadowJar
    

    to create a jar file of your project. It’ll be located in the build/libs directory as some-name.jar file. You can run this file with the command

    java -jar some-name.jar
    

    The jar file contains all dependencies from your project (also your classes) so it can be distributed as final effect of your project. This task is configured with some Gradle plugin - just in case if you would like to deep dive into this configuration.

Task

You can find task with its description here. Your goal is to provide the implementation marked with “TODO” and create a pull request for review.

Fork this repository, make your changes in IDE, create commit, push it (send) to GitHub and create pull request to my repository. Then email me with some short info that you created a pull request - I’ll check it and give you some feedback if it’s submitted properly.

Some hints

  1. Ask any questions (about task description or submitting task) using our slack or mail
  2. You can represent big numbers as consecutive digits - we don’t have to think about performance of our implementation
  3. You need to provide an implementation for places with throw new IllegalStateException("TODO task x: short task description"); - just remove the line with throw new ... and write your code.
  4. Your implementation should pass tests that are already prepared and the tests provided by you - you can check the status of your tests in the repository actions.
  5. You need to provide the implementation of public String toString() - for now, don’t worry about @Override modifier
  6. You can see how to configure GitHub with SSH keys using these instructions.
  7. I recommended you some cool Java book - let’s take a look at Effective Java - it’s definitely not required for this task and even course, but it’s a perfect book about Java
Previous
Next