This commit is contained in:
Johannes Theiner 2018-04-06 13:09:50 +02:00
parent 689253c1fb
commit 344484735f
2 changed files with 11 additions and 5 deletions

View File

@ -1,15 +1,20 @@
package de.joethei.hs.java2.praktikum.praktikum2;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class CharCollection {
ArrayList<Character> list = new ArrayList<>();
public CharCollection(char... cc) {
for(char c:cc) this.list.add(c);
}
public CharCollection(String s) {
new CharCollection(s.toCharArray());
for(char c : s.toCharArray()) {
this.list.add(c);
}
}
@ -44,6 +49,6 @@ public class CharCollection {
}*/
public String toString() {
return list.toString();
return list.toString().replace('[', '(').replace(']', ')');
}
}

View File

@ -32,11 +32,12 @@ public class CharCollectionTest {
public void top() {
assertEquals('l', new CharCollection("Hallo").top());
}
*/
@Test
public void toStringTest() {
assertEquals("HalloWelt", new CharCollection("HalloWelt").toString());
assertEquals("(H, a, l, l, o, W, e, l, t)", new CharCollection("HalloWelt").toString());
}
/*
@Test
public void moreThan() {