0
의 특정 데이터 형식으로 개체 변환 따라서 아래E
또는 일반 데이터 형식을 반환합니다.toString 메서드
public String toString() {
StringBuilder linkedQueueAsString = new StringBuilder();
linkedQueueAsString.append("< ");
for (Link<E> node = this.front.getNextNode(); node != null; node = node.getNextNode())
{
linkedQueueAsString.append(node.getValue()); // <=== Not working correctly
linkedQueueAsString.append(" ");
}
linkedQueueAsString.append(">");
return linkedQueueAsString.toString();
}
나는 다음 내 테스트처럼 테스트입니다 실패
public void setUp() {
this.queue1 = new LinkedQueue<Integer>();
this.queue2 = new LinkedQueue<Integer>();
}
public void test_enqueue3IntegersAndThenDequeueThem() {
this.queue2.enqueue(1);
this.queue2.enqueue(2);
this.queue2.enqueue(3);
assertEquals(3, this.queue2.length());
assertEquals("< 1 2 3 >", this.queue2.toString()); // <= ERROR since none of the numbers printed out
}
당신은 링크 큐 here의 개인 구현을 볼 수 있습니다.
어떻게 해결할 수 있습니까? 감사!
질문을 한 줄 또는 두 줄로 요약 할 수 있다면 도움이 될 것입니다. "올바르게 작동하지 않음"이란 무엇입니까? –
나머지 코드는 게시하여 사용해 볼 수 있습니다. 나는 그것을 시도하면 효과가 있다고 느낀다. – tbodt
그래서 E는 무엇입니까? 이것은 더 많은 맥락이 필요합니다. 또한 들여 쓰기를 수정하십시오. –