Posted: 05 September 2019

Deadline: 2019-09-21 16:00

This second assignment contains 8 questions that should be possible to answer with the material from the classes and a small programming exercise.

The answers to both must be submitted in the E-test section in Blackboard before deadline.

The programming exercise is described below.

Programming Exercise - Character Conversion

The goal of this programming exercise is to get you more comfortable with a Java build tool, a test framework and TDD, and work a tiny bit more with the Java class BigInteger. We will later in the course, when we will cover security need BigInteger calculations.

To complete this part of the assignment, you must download the character-conversion.zip and unpack.

While the assignment has links to Gradle, Spock and Groovy, it should not be necessary to study those in details. Instructions are included in the assignment text.

Introduction

Gradle

Gradle is a powerfull build tool used for building and executing larger Java projects. It comes with a Gradle wrapper, so it can bootstrap itself. The build specification is in the file build.gradle, but don’t worry, it is set up for you.

You can run the application using the command

./gradlew run

It will compile and execute the Main method in the Main class, located in src/main/java/dk/sdu/imada/Main.java

You can also use Gradle to execute the tests. For this use

./gradlew test
Tip
If you are on windows, use gradlew.bat instead of gradlew
Warning
There is no need to compile your Java class with javac, you should let Gradle do the compilation and test for you.

Spock Tests

Spock is a test framework, that using the Groovy language is very powerfull and readable to write test specifications in.

You can find the tests written for the Fibonnacci calculation in the file src/test/groovy/dk/sdu/imada/NumberCalculationsSpec.groovy

The Tasks

Implement code for to make each test pass, running the tests regularly.

What to turn in?

You must turn in the source code of the CharacterConversion class once it passes the tests