diff --git a/proj1a/src/LinkedListDeque61B.java b/proj1a/src/LinkedListDeque61B.java new file mode 100644 index 0000000..8c55250 --- /dev/null +++ b/proj1a/src/LinkedListDeque61B.java @@ -0,0 +1,62 @@ +import java.util.List; + +public class LinkedListDeque61B implements Deque61B { + + public LinkedListDeque61B() { + + } + @Override + public void addFirst(T x) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'addFirst'"); + } + + @Override + public void addLast(T x) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'addLast'"); + } + + @Override + public List toList() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'toList'"); + } + + @Override + public boolean isEmpty() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'isEmpty'"); + } + + @Override + public int size() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'size'"); + } + + @Override + public T removeFirst() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'removeFirst'"); + } + + @Override + public T removeLast() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'removeLast'"); + } + + @Override + public T get(int index) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'get'"); + } + + @Override + public T getRecursive(int index) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getRecursive'"); + } + +} \ No newline at end of file diff --git a/proj1a/tests/LinkedListDeque61BTest.java b/proj1a/tests/LinkedListDeque61BTest.java index 7c47bf2..bfa4d62 100644 --- a/proj1a/tests/LinkedListDeque61BTest.java +++ b/proj1a/tests/LinkedListDeque61BTest.java @@ -8,53 +8,53 @@ /** Performs some basic linked list tests. */ public class LinkedListDeque61BTest { - // @Test - // /** In this test, we have three different assert statements that verify that addFirst works correctly. */ - // public void addFirstTestBasic() { - // Deque61B lld1 = new LinkedListDeque61B<>(); - - // lld1.addFirst("back"); // after this call we expect: ["back"] - // assertThat(lld1.toList()).containsExactly("back").inOrder(); - - // lld1.addFirst("middle"); // after this call we expect: ["middle", "back"] - // assertThat(lld1.toList()).containsExactly("middle", "back").inOrder(); - - // lld1.addFirst("front"); // after this call we expect: ["front", "middle", "back"] - // assertThat(lld1.toList()).containsExactly("front", "middle", "back").inOrder(); - - // /* Note: The first two assertThat statements aren't really necessary. For example, it's hard - // to imagine a bug in your code that would lead to ["front"] and ["front", "middle"] failing, - // but not ["front", "middle", "back"]. - // */ - // } - - // @Test - // /** In this test, we use only one assertThat statement. IMO this test is just as good as addFirstTestBasic. - // * In other words, the tedious work of adding the extra assertThat statements isn't worth it. */ - // public void addLastTestBasic() { - // Deque61B lld1 = new LinkedListDeque61B<>(); - - // lld1.addLast("front"); // after this call we expect: ["front"] - // lld1.addLast("middle"); // after this call we expect: ["front", "middle"] - // lld1.addLast("back"); // after this call we expect: ["front", "middle", "back"] - // assertThat(lld1.toList()).containsExactly("front", "middle", "back").inOrder(); - // } - - // @Test - // /** This test performs interspersed addFirst and addLast calls. */ - // public void addFirstAndAddLastTest() { - // Deque61B lld1 = new LinkedListDeque61B<>(); - - // /* I've decided to add in comments the state after each call for the convenience of the - // person reading this test. Some programmers might consider this excessively verbose. */ - // lld1.addLast(0); // [0] - // lld1.addLast(1); // [0, 1] - // lld1.addFirst(-1); // [-1, 0, 1] - // lld1.addLast(2); // [-1, 0, 1, 2] - // lld1.addFirst(-2); // [-2, -1, 0, 1, 2] - - // assertThat(lld1.toList()).containsExactly(-2, -1, 0, 1, 2).inOrder(); - // } + @Test + /** In this test, we have three different assert statements that verify that addFirst works correctly. */ + public void addFirstTestBasic() { + Deque61B lld1 = new LinkedListDeque61B<>(); + + lld1.addFirst("back"); // after this call we expect: ["back"] + assertThat(lld1.toList()).containsExactly("back").inOrder(); + + lld1.addFirst("middle"); // after this call we expect: ["middle", "back"] + assertThat(lld1.toList()).containsExactly("middle", "back").inOrder(); + + lld1.addFirst("front"); // after this call we expect: ["front", "middle", "back"] + assertThat(lld1.toList()).containsExactly("front", "middle", "back").inOrder(); + + /* Note: The first two assertThat statements aren't really necessary. For example, it's hard + to imagine a bug in your code that would lead to ["front"] and ["front", "middle"] failing, + but not ["front", "middle", "back"]. + */ + } + + @Test + /** In this test, we use only one assertThat statement. IMO this test is just as good as addFirstTestBasic. + * In other words, the tedious work of adding the extra assertThat statements isn't worth it. */ + public void addLastTestBasic() { + Deque61B lld1 = new LinkedListDeque61B<>(); + + lld1.addLast("front"); // after this call we expect: ["front"] + lld1.addLast("middle"); // after this call we expect: ["front", "middle"] + lld1.addLast("back"); // after this call we expect: ["front", "middle", "back"] + assertThat(lld1.toList()).containsExactly("front", "middle", "back").inOrder(); + } + + @Test + /** This test performs interspersed addFirst and addLast calls. */ + public void addFirstAndAddLastTest() { + Deque61B lld1 = new LinkedListDeque61B<>(); + + /* I've decided to add in comments the state after each call for the convenience of the + person reading this test. Some programmers might consider this excessively verbose. */ + lld1.addLast(0); // [0] + lld1.addLast(1); // [0, 1] + lld1.addFirst(-1); // [-1, 0, 1] + lld1.addLast(2); // [-1, 0, 1, 2] + lld1.addFirst(-2); // [-2, -1, 0, 1, 2] + + assertThat(lld1.toList()).containsExactly(-2, -1, 0, 1, 2).inOrder(); + } // Below, you'll write your own tests for LinkedListDeque61B. } \ No newline at end of file