Adding the original version from the blog.

This commit is contained in:
shing19m
2013-07-23 20:10:47 +02:00
parent 634e4614f7
commit fa2f2f7d7a
5 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package b1;
import java.io.IOException;
import java.io.PrintWriter;
import jline.ConsoleReader;
public class Main {
public static void main(String[] args) throws IOException {
ConsoleReader reader = new ConsoleReader();
String line;
PrintWriter out = new PrintWriter(System.out);
while ((line = reader.readLine("number or quit> ")) != null) {
if (line.equalsIgnoreCase("quit")) {
break;
}
int i = Integer.parseInt(line);
System.out.println(
Math.square(i) + " ist " + i + " quadriert");
out.flush();
}
}
}

View File

@@ -0,0 +1,8 @@
package b1;
public class Math {
public static int square(int a) {
return a * a;
}
}

View File

@@ -0,0 +1,12 @@
package b1;
import org.junit.Assert;
import org.junit.Test;
public class MathTest {
@Test
public void testSqure() {
Assert.assertEquals(16, Math.square(4));
}
}