Commit 7394c246 authored by Anya Helene Bagge's avatar Anya Helene Bagge 🦆

Lagt til implementasjon og test av clear()-metoden

Mer beskrivelse
parent 72a931aa
......@@ -47,4 +47,9 @@ public class MyStack implements IStack {
return length;
}
@Override
public void clear() {
length = 0;
}
}
......@@ -32,5 +32,17 @@ public class StackTest {
assertEquals("Kaffe", stack.pop());
assertEquals("Hei", stack.pop());
}
@Test
public void clearTest() {
IStack stack = new MyStack();
stack.push("Hei");
stack.push("Kaffe");
stack.clear();
assertTrue(stack.isEmpty());
assertEquals(0, stack.size());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment