### Question:
CircularArraySequence implements Sequence { @Override public Object last() { CircularArraySequence<T> tempSequence = new CircularArraySequence<T>(this); T lastObj; if (rear == 0){ if (tempSequence.backingArray[tempSequence.backingArray.length-1]==null && tempSequence.backingArray[tempSequence.rear] != null){ lastObj = tempSequence.backingArray[tempSequence.rear]; backingArray[rear] = null; fillCount-=1; rear = 0; } else if(tempSequence.backingArray[tempSequence.backingArray.length-1]==null && tempSequence.backingArray[tempSequence.rear] == null){ lastObj = null; } else{ lastObj = tempSequence.backingArray[tempSequence.backingArray.length-1]; backingArray[backingArray.length-1] = null; fillCount-=1; rear = tempSequence.backingArray.length-1; } } else{ lastObj = (T) tempSequence.backingArray[tempSequence.rear-1]; backingArray[rear-1] = null; fillCount-=1; rear-=1; } return lastObj; } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); @Override Object head(); @Override Object last(); @Override Sequence front(); @Override Sequence tail(); @Override Sequence<T> concat(Sequence seq); @Override boolean contains(Sequence subseq); @Override boolean contains(Object element); @Override void append(Object element); @Override void prepend(Object element); @Override boolean isEmpty(); @Override Object peekHead(); @Override Object peekLast(); @Override boolean equals(Sequence seq); @Override int length(); @Override Iterator<T> iterator(); String toString();  }### Answer:
@Test public void testLast() { assertTrue("New sequence not reporting empty", seq.isEmpty()); assertEquals("Taking last of an new empty sequence did not return null", null, seq.last()); seq.append("a"); seq.append("b"); seq.append("c"); assertEquals("Last element returned not correct", "c", seq.last()); assertEquals("Number of elements wrong after last called", 2, seq.length()); assertEquals("last element returned not correct", "b", seq.last()); assertEquals("Number of elements wrong after last called", 1, seq.length()); assertEquals("Last element returned not correct", "a", seq.last()); assertEquals("Taking last of an empty sequence didn't return null", null, seq.last()); }