From a55c938921a0f168bc56104b2a139ddb5ce75e82 Mon Sep 17 00:00:00 2001 From: abhinandshibu <53155408+abhinandshibu@users.noreply.github.com> Date: Thu, 11 Mar 2021 13:14:19 +0000 Subject: [PATCH] Typo fix --- questions/85bb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/questions/85bb.md b/questions/85bb.md index cef50a4..7919f11 100644 --- a/questions/85bb.md +++ b/questions/85bb.md @@ -55,7 +55,7 @@ You should now find that `StringStackArray` and `StringStackList` no longer compile. This is because they do not implement the `iterator` method. ### Step 3 -In order to fix this, you need to create two new classes: `StringStackArray``Iterator`, +In order to fix this, you need to create two new classes: `StringStackArrayIterator`, and `StringStackListIterator`. Both classes should implement the `StringStackIterator` interface. Writing these classes is a little tricky, but once you have them, implementing the `iterator` method in `StringStackArray` is straightforward: simply @@ -64,7 +64,7 @@ return a new `StringStackArrayIterator`; implementing `iterator` in So, how should you implement the iterator classes? There are two choices: -1. Create a fresh class for each of `StringStackArrayIterator` and `StringStack``ListIterator`. +1. Create a fresh class for each of `StringStackArrayIterator` and `StringStackListIterator`. Let us consider the `StringStackArrayIterator` case. `StringStackArrayIterator` should have a field of type `String[]`: a reference to the contents of the stack. In addition, this class should have a field of type `int` that refers to the stack element that the iterator is currently pointing to. This should be initialised to the top of the stack. This solution is OK, but it requires the internal details of a `StringStackArray` to be indirectly exposed to the separate `StringStackArrayIterator` class, since a `StringStackArrayIterator` is constructed using the internals of a `StringStackArray`. More importantly, this setup allows clients to construct instances of `StringStackArrayIterator` *independently* of any actual `StringStackArray`. This doesn't really make sense. The extent of this problem can be limited by making the `StringStackArrayIterator` only package visible.