Initial Commit
This commit is contained in:
commit
0c1e1df1f4
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/.idea/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public class Apfelsaft implements Zutat{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public class Banane implements Zutat {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Cocktail {
|
||||||
|
|
||||||
|
public int getAnzahlZutaten() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public interface CocktailMixer {
|
||||||
|
void hinzufuegen(Zutat zutat);
|
||||||
|
Cocktail mixen() throws EkligeZutatenKombinationException;
|
||||||
|
int getAnzahlZutaten();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public class EkligeZutatenKombinationException extends Exception {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// write your code here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public class Milch implements Zutat{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class StandardCocktailMixer implements CocktailMixer{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hinzufuegen(Zutat zutat) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cocktail mixen() throws EkligeZutatenKombinationException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAnzahlZutaten() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// gegeben
|
||||||
|
public static <T> boolean enthaelt(Collection<?> collection, Class<T> klasse) {
|
||||||
|
for (Object o : collection) {
|
||||||
|
if (o != null && o.getClass() == klasse) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
public interface Zutat {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package gfn.marc;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class CocktailMixerTest {
|
||||||
|
|
||||||
|
CocktailMixer cocktailMixer;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
this.cocktailMixer = new StandardCocktailMixer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testeCocktailMixer() throws EkligeZutatenKombinationException {
|
||||||
|
Cocktail cocktail = cocktailMixer.mixen();
|
||||||
|
assertNotNull(cocktail);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testeAnzahlZutatenInMixer() {
|
||||||
|
Banane banene = new Banane();
|
||||||
|
Milch milch = new Milch();
|
||||||
|
cocktailMixer.hinzufuegen(banene);
|
||||||
|
cocktailMixer.hinzufuegen(milch);
|
||||||
|
assertEquals(2, cocktailMixer.getAnzahlZutaten());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testeAnzahlZutatenInCocktail() throws EkligeZutatenKombinationException {
|
||||||
|
Banane banene = new Banane();
|
||||||
|
Milch milch = new Milch();
|
||||||
|
cocktailMixer.hinzufuegen(banene);
|
||||||
|
cocktailMixer.hinzufuegen(milch);
|
||||||
|
Cocktail cocktail = cocktailMixer.mixen();
|
||||||
|
assertEquals(0, cocktailMixer.getAnzahlZutaten());
|
||||||
|
assertEquals(2, cocktail.getAnzahlZutaten());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test (expected = EkligeZutatenKombinationException.class)
|
||||||
|
public void testeEkligeZutatenKombination() throws EkligeZutatenKombinationException {
|
||||||
|
Banane banane = new Banane();
|
||||||
|
Apfelsaft apfelsaft = new Apfelsaft();
|
||||||
|
cocktailMixer.hinzufuegen(banane);
|
||||||
|
cocktailMixer.hinzufuegen(apfelsaft);
|
||||||
|
Cocktail cocktail = cocktailMixer.mixen();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue