feat: add Lab4

This commit is contained in:
Yadunand Prem
2022-09-15 11:21:56 +08:00
parent c4d857ed02
commit 46d4fa5e9d
116 changed files with 912 additions and 2 deletions

23
Lab1/QueueTest.java Executable file
View File

@@ -0,0 +1,23 @@
class QueueTest {
public static void main(String[] args) {
CS2030STest i = new CS2030STest();
Queue<Integer> q = new Queue<Integer>(2);
i.expect("insert 4 into a queue of integer",
q.enq(4), true);
i.expect("insert 8 into a queue of integer",
q.enq(8), true);
i.expect("insert 0 into a full queue",
q.enq(0), false);
i.expect("remove 4 from queue",
q.deq(), 4);
i.expect("remove 8 from queue",
q.deq(), 8);
i.expect("cannot deque anymore",
q.deq(), null);
i.expectCompile("cannot deque a non-integer from a queue of integer",
"String s = new Queue<Integer>(3).deq();", false);
i.expectCompile("cannot insert a non-integer into a queue of integer",
"new Queue<Integer>(3).enqueue(false);", false);
}
}