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.
- Test task
runs test classes from your project. The classes that contain methods with
@Testannotation are the definitions of unit tests for your classes - they’ll be executed for this task.
- Package app task
to create a jar file of your project. It’ll be located in the
some-name.jarfile. 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.
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.
- Ask any questions (about task description or submitting task) using our slack or mail
- You can represent big numbers as consecutive digits - we don’t have to think about performance of our implementation
- 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.
- 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.
- You need to provide the implementation of
public String toString()- for now, don’t worry about
- You can see how to configure GitHub with SSH keys using these instructions.
- 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