Compare commits
No commits in common. "marc" and "master" have entirely different histories.
|
|
@ -3,13 +3,8 @@ package gfn.marc;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Cocktail {
|
public class Cocktail {
|
||||||
private List<Zutat> zutaten;
|
|
||||||
|
|
||||||
public Cocktail(List<Zutat> zutaten) {
|
|
||||||
this.zutaten = zutaten;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAnzahlZutaten() {
|
public int getAnzahlZutaten() {
|
||||||
return this.zutaten.size();
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,27 @@
|
||||||
package gfn.marc;
|
package gfn.marc;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class StandardCocktailMixer implements CocktailMixer{
|
public class StandardCocktailMixer implements CocktailMixer{
|
||||||
|
|
||||||
List<Zutat> zutaten = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hinzufuegen(Zutat zutat) {
|
public void hinzufuegen(Zutat zutat) {
|
||||||
this.zutaten.add(zutat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cocktail mixen() throws EkligeZutatenKombinationException {
|
public Cocktail mixen() throws EkligeZutatenKombinationException {
|
||||||
if (enthaelt(this.zutaten, Banane.class) && enthaelt(this.zutaten, Apfelsaft.class)) {
|
return null;
|
||||||
throw new EkligeZutatenKombinationException();
|
|
||||||
}
|
|
||||||
List<Zutat> zutaten = new ArrayList<>(this.zutaten);
|
|
||||||
this.zutaten.clear();
|
|
||||||
return new Cocktail(zutaten);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAnzahlZutaten() {
|
public int getAnzahlZutaten() {
|
||||||
return this.zutaten.size();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// gegeben
|
||||||
public static <T> boolean enthaelt(Collection<?> collection, Class<T> klasse) {
|
public static <T> boolean enthaelt(Collection<?> collection, Class<T> klasse) {
|
||||||
for (Object o : collection) {
|
for (Object o : collection) {
|
||||||
if (o != null && o.getClass() == klasse) {
|
if (o != null && o.getClass() == klasse) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue