Skip to content
Snippets Groups Projects
Commit dd4c4928 authored by Goik Martin's avatar Goik Martin
Browse files

Removing old exercise variant

parent 713c5df9
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 431 deletions
/.settings
/target
/.classpath
/.project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hdm-stuttgart.de.sd1</groupId>
<artifactId>diff</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Diff</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package de.hdm_stuttgart.mi.sd1.store;
/**
* Additional helper methods
*
*/
public class Diff {
/**
* Compute the absolute value of the biggest difference between
* two of three given numbers a, b, and c
*
* Examples:
*
* a == 1, b == 2, c ==10, the biggest absolute difference is 10 - 1 = 9
* a == 4, b ==10, c == 1, the biggest absolute difference is 10 - 1 = 9
* a ==-3, b == 4, c == 3, the biggest absolute difference is 4 - (-3) = 7
*
*
* @param a The first of three parameters
* @param b The second of three parameters
* @param c The third of three parameters
* @return The absolute value of the biggest difference between two arbitrary parameters
*/
public static int maxDiff(int a, int b, int c) {
return 0; // TODO: Implementation to be completed
}
}
/**
* Dealing with difference values
*
*/
package de.hdm_stuttgart.mi.sd1.store;
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.fraction;
import static org.junit.Assert.*;
import org.junit.Test;
import de.hdm_stuttgart.mi.sd1.store.Diff;
/**
* Testing max diff function
*
*/
public class DiffTest {
/**
* Test absolute maximal difference
*/
/* TODO: Remove me to activate testing
@Test
*/
public void testDiff() {
assertEquals(0, Diff.maxDiff(0, 0, 0));
assertEquals(0, Diff.maxDiff(1, 1, 1));
assertEquals(2, Diff.maxDiff(1, 2, 3));
assertEquals(3, Diff.maxDiff(4, 1, 4));
assertEquals(3, Diff.maxDiff(-1, -2, -4));
assertEquals(1, Diff.maxDiff(2, 2, 3));
}
}
/.settings
/target
/.classpath
/.project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hdm-stuttgart.de.sd1</groupId>
<artifactId>diff</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>Diff</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package de.hdm_stuttgart.mi.sd1.store;
/**
* Additional helper methods
*
*/
public class Diff {
/**
* Compute the absolute value of the biggest difference between
* two of three given numbers a, b, and c
*
* Examples:
*
* a == 1, b == 2, c ==10, the biggest absolute difference is 10 - 1 = 9
* a == 4, b ==10, c == 1, the biggest absolute difference is 10 - 1 = 9
* a ==-3, b == 4, c == 3, the biggest absolute difference is 4 - (-3) = 7
*
*
* @param a The first of three parameters
* @param b The second of three parameters
* @param c The third of three parameters
* @return The absolute value of the biggest difference between two arbitrary parameters
*/
public static int maxDiff(int a, int b, int c) {
final int ab = Math.abs(a - b),
ac = Math.abs(a - c),
bc = Math.abs(b - c);
return Math.max(ab, Math.max(ac, bc));
}
}
/**
* Dealing with integer stores.
*
*/
package de.hdm_stuttgart.mi.sd1.store;
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.fraction;
import static org.junit.Assert.*;
import org.junit.Test;
import de.hdm_stuttgart.mi.sd1.store.Diff;
/**
* Testing max diff function
*
*/
public class DiffTest {
/**
* Test absolute maximal difference
*/
@Test
public void testDiff() {
assertEquals(0, Diff.maxDiff(0, 0, 0));
assertEquals(0, Diff.maxDiff(1, 1, 1));
assertEquals(2, Diff.maxDiff(1, 2, 3));
assertEquals(3, Diff.maxDiff(4, 1, 4));
assertEquals(3, Diff.maxDiff(-1, -2, -4));
assertEquals(1, Diff.maxDiff(2, 2, 3));
}
}
/.settings
/target
/.classpath
/.project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hdm-stuttgart.de.sd1</groupId>
<artifactId>maxarraydiff</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>MaxArrayDiff</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package de.hdm_stuttgart.mi.sd1.maxarraydiff;
/**
* Array calculations.
*
*/
public class Calc {
/**
* Calculate the maximum of all mutual absolute
* difference values. Example:
*
* values = {1, 7, 2, -3, 4}
*
* The maximum is 7 - (-3) = 10
*
*
* @param values An unordered list of integer values
* @return The number of vowels being contained in s.
*/
public static int maxArrayDiff (final int [] values) {
int maxDiff = 0;
for (int i = 0; i < values.length; i++) {
for (int j = i + 1; j < values.length; j++) {
if (maxDiff < Math.abs(values[i] -values[j])) {
maxDiff = Math.abs(values[i] -values[j]);
}
}
}
return maxDiff;
}
}
/**
* Computing array value differences
*
*/
package de.hdm_stuttgart.mi.sd1.maxarraydiff;
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.fraction;
import org.junit.Assert;
import org.junit.Test;
import de.hdm_stuttgart.mi.sd1.maxarraydiff.Calc;
@SuppressWarnings("javadoc")
public class CalcTest {
@Test public void testZero() {
Assert.assertEquals(0, Calc.maxArrayDiff(new int[]{}));
}
@Test public void testOne() {
Assert.assertEquals(0, Calc.maxArrayDiff(new int[]{-3}));
}
@Test public void testTwo() {
Assert.assertEquals(4, Calc.maxArrayDiff(new int[]{1, -3}));
}
@Test public void testThree() {
Assert.assertEquals(13, Calc.maxArrayDiff(new int[]{1, 4, -9}));
}
@Test public void testMulti() {
Assert.assertEquals(17, Calc.maxArrayDiff(new int[]{ -1, 0, -5, 3, 5, 12, 8}));
}
}
/.settings
/target
/.classpath
/.project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hdm-stuttgart.de.sd1</groupId>
<artifactId>maxarraydiff</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>MaxArrayDiff</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package de.hdm_stuttgart.mi.sd1.maxarraydiff;
/**
* Array calculations.
*
*/
public class Calc {
/**
* Calculate the maximum of all mutual absolute
* difference values. Example:
*
* values = {1, 7, 2, -3, 4}
*
* The maximum is 7 - (-3) = 10
*
*
* @param values An unordered list of integer values
* @return The number of vowels being contained in s.
*/
public static int maxArrayDiff (final int [] values) {
return 0; // TODO
}
}
/**
* Computing array value differences
*
*/
package de.hdm_stuttgart.mi.sd1.maxarraydiff;
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1;
import org.junit.Assert;
import org.junit.Test;
import de.hdm_stuttgart.mi.sd1.maxarraydiff.Calc;
@SuppressWarnings("javadoc")
public class CalcTest {
// TODO: uncomment the following @test annotations
// TODO @Test
public void testZero() {
Assert.assertEquals(0, Calc.maxArrayDiff(new int[]{}));
}
// TODO @Test
public void testOne() {
Assert.assertEquals(0, Calc.maxArrayDiff(new int[]{-3}));
}
// TODO @Test
public void testTwo() {
Assert.assertEquals(4, Calc.maxArrayDiff(new int[]{1, -3}));
}
// TODO @Test
public void testThree() {
Assert.assertEquals(13, Calc.maxArrayDiff(new int[]{1, 4, -9}));
}
// TODO @Test
public void testMulti() {
Assert.assertEquals(17, Calc.maxArrayDiff(new int[]{ -1, 0, -5, 3, 5, 12, 8}));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment