jgoraho
This commit is contained in:
parent
689253c1fb
commit
344484735f
@ -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(']', ')');
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user