From fa2f2f7d7a2313ad234e09cdd86a80a6cf291f2d Mon Sep 17 00:00:00 2001 From: shing19m Date: Tue, 23 Jul 2013 20:10:47 +0200 Subject: [PATCH] Adding the original version from the blog. --- .gitignore | 1 + pom.xml | 73 ++++++++++++++++++++++++++++++++++ src/main/java/b1/Main.java | 23 +++++++++++ src/main/java/b1/Math.java | 8 ++++ src/test/java/b1/MathTest.java | 12 ++++++ 5 files changed, 117 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/b1/Main.java create mode 100644 src/main/java/b1/Math.java create mode 100644 src/test/java/b1/MathTest.java diff --git a/.gitignore b/.gitignore index 0f182a0..8685af6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.jar *.war *.ear +/target/ \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..327418d --- /dev/null +++ b/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + de.lusiardi.maven + mavenExecutableJarFiles + jar + 0.1 + Ausführbare Jar-Dateien mit Maven + + + + + org.apache.maven.plugins + + + maven-compiler-plugin + + 2.1 + + + 1.5 + + + 1.5 + + UTF-8 + + + + org.apache.maven.plugins + maven-shade-plugin + 1.4 + + + package + + shade + + + + + b1.Main + + + + + + + + + + + junit + junit + 4.8.2 + test + + + jline + jline + 0.9.9 + + + + + jline + JLine Project Repository + http://jline.sourceforge.net/m2repo + + + \ No newline at end of file diff --git a/src/main/java/b1/Main.java b/src/main/java/b1/Main.java new file mode 100644 index 0000000..acb4bcd --- /dev/null +++ b/src/main/java/b1/Main.java @@ -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(); + } + } +} \ No newline at end of file diff --git a/src/main/java/b1/Math.java b/src/main/java/b1/Math.java new file mode 100644 index 0000000..e111fe5 --- /dev/null +++ b/src/main/java/b1/Math.java @@ -0,0 +1,8 @@ +package b1; + +public class Math { + + public static int square(int a) { + return a * a; + } +} diff --git a/src/test/java/b1/MathTest.java b/src/test/java/b1/MathTest.java new file mode 100644 index 0000000..21a5999 --- /dev/null +++ b/src/test/java/b1/MathTest.java @@ -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)); + } +} \ No newline at end of file