diff --git a/src/main/java/edu/unl/edu/soft160/testDemo/App.java b/src/main/java/edu/unl/edu/soft160/testDemo/App.java deleted file mode 100644 index 0eda15bf98888ee1d33fb7e544cc3f4058a826a3..0000000000000000000000000000000000000000 --- a/src/main/java/edu/unl/edu/soft160/testDemo/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package edu.unl.edu.soft160.testDemo; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/src/main/java/edu/unl/edu/soft160/testDemo/TestDemoTarget.java b/src/main/java/edu/unl/edu/soft160/testDemo/TestDemoTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..56514a9c5a70d037270e6732e059c34334f46c2d --- /dev/null +++ b/src/main/java/edu/unl/edu/soft160/testDemo/TestDemoTarget.java @@ -0,0 +1,46 @@ +package edu.unl.edu.soft160.testDemo; + +import java.util.Scanner; + +public class TestDemoTarget { + public static int getMaximum(int firstValue, int secondValue) { + int returnValue = Integer.MIN_VALUE; + if (firstValue > secondValue) { + returnValue = firstValue; + } else if (secondValue > firstValue) { + returnValue = secondValue; + } + return returnValue; + } + + public static double getMaximum(double firstValue, double secondValue) { + double returnValue = Double.NaN; + if (firstValue > secondValue) { + returnValue = firstValue; + } else if (secondValue > firstValue) { + returnValue = secondValue; + } + return returnValue; + } + + public static double multiplyByTen(double multiplicand) { + double multiplier = 0.0; + for (int i = 0; i < 100; i++) { + multiplier += 0.1; + } + return multiplicand * multiplier; + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.print("Enter first value: "); + double firstValue = Double.valueOf(scanner.nextLine()); + System.out.print("Enter secondValue: "); + double secondValue = Double.valueOf(scanner.nextLine()); + scanner.close(); + System.out.println( + "The maximum of " + firstValue + " and " + secondValue + " is " + getMaximum(firstValue, secondValue)); + System.out.println("Multiplying " + firstValue + " ⨉ 10 = " + multiplyByTen(firstValue)); + System.out.println("Multiplying " + secondValue + " ⨉ 10 = " + multiplyByTen(secondValue)); + } +} diff --git a/src/test/java/edu/unl/edu/soft160/testDemo/AppTest.java b/src/test/java/edu/unl/edu/soft160/testDemo/AppTest.java deleted file mode 100644 index ccee6d258fb3ff7c38667d469ccb229977c23f62..0000000000000000000000000000000000000000 --- a/src/test/java/edu/unl/edu/soft160/testDemo/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package edu.unl.edu.soft160.testDemo; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/src/test/java/edu/unl/edu/soft160/testDemo/TestDemoTests.java b/src/test/java/edu/unl/edu/soft160/testDemo/TestDemoTests.java new file mode 100644 index 0000000000000000000000000000000000000000..f856cd04a714b58447e549ca6a043b02ae31e09e --- /dev/null +++ b/src/test/java/edu/unl/edu/soft160/testDemo/TestDemoTests.java @@ -0,0 +1,30 @@ +package edu.unl.edu.soft160.testDemo; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class TestDemoTests { + @Test + public void testIntegerFirstValueIsGreater() { + // arrange + int firstValue = 3; + int secondValue = 5; + int expectedResult = 5; + // act + int actualResult = TestDemoTarget.getMaximum(firstValue, secondValue); + // assert + assertEquals(expectedResult, actualResult); + } + + @Test + public void testDoubleFirstValueIsGreater() { + // arrange + double firstValue = 3.5; + double secondValue = 5.2; + double expectedResult = 5.2; + // act + double actualResult = TestDemoTarget.getMaximum(firstValue, secondValue); + // assert + assertEquals(expectedResult, actualResult, 0.0); + } +}