Question: Hello. This is a Java problem. Im supposed to complete the methods in this class. The methods already written and it requires one more class

Hello. This is a Java problem. Im supposed to complete the methods in this class. The methods already written and it requires one more class and ill paste both. And the question just in case. I'm supposed to complete the class "ArrayedBinaryTreeIterator280" and it extends one class and implements one interface. I will post it just incase but I just need to complete the methods in "ArrayedBinaryTreeIterator280" only. Please help I'm lost.

package lib280.tree;

import lib280.base.LinearIterator280;

import lib280.exception.AfterTheEnd280Exception;

import lib280.exception.ContainerEmpty280Exception;

import lib280.exception.NoCurrentItem280Exception;

public class ArrayedBinaryTreeIterator280 extends ArrayedBinaryTreePosition280 implements LinearIterator280 {

// This is a reference to the tree that created this iterator object.

ArrayedBinaryTree280 tree;

// An integer that represents the cursor position is inherited from

// ArrayedBinaryTreePosition280.

/**

* Create a new iterator from a given heap.

* @param t The heap for which to create a new iterator.

*/

public ArrayedBinaryTreeIterator280(ArrayedBinaryTree280 t) {

super(t.currentNode);

this.tree = t;

}

// TODO - Complete the following methods which are required by LinearIterator280

// Note that these method stubs were automatically generated by IntelliJ and every one of them

// requires your attention.

@Override

public boolean before() {

return false;

}

@Override

public boolean after() {

return false;

}

@Override

public void goForth() throws AfterTheEnd280Exception {

}

@Override

public void goFirst() throws ContainerEmpty280Exception {

}

@Override

public void goBefore() {

}

@Override

public void goAfter() {

}

@Override

public I item() throws NoCurrentItem280Exception {

return null;

}

@Override

public boolean itemExists() {

return false;

}

}

#Interface

/* LinearIterator280.java

* ---------------------------------------------

* Copyright (c) 2004 University of Saskatchewan

* All Rights Reserved

* --------------------------------------------- */

package lib280.base;

import lib280.exception.AfterTheEnd280Exception;

import lib280.exception.ContainerEmpty280Exception;

/** A basic iterator for moving through a collection of items linearly.

It utilizes a cursor to keep track of the current item of the

sequence, and has functions to move forward and to the front of

the sequence. */

public interface LinearIterator280 extends Cursor280

{

/** Is the current position before the start of the structure?. */

public boolean before();

/** Is the current position after the end of the structure?. */

public boolean after();

/** Advance one item in the data structure.

* @precond !after()

* @throws AfterTheEnd280Exception if the cursor is already in the after position and cannot be advanced.

*/

public void goForth() throws AfterTheEnd280Exception;

/**

* Go to the first item in the structure.

* @precond !isEmpty()

* @throws ContainerEmpty280Exception if this container is empty.

*/

public void goFirst() throws ContainerEmpty280Exception;

/** Move to the position prior to the first element in the structure. */

public void goBefore();

/** Move to the position after the last element in the structure. */

public void goAfter();

}

package lib280.tree;

import lib280.base.CursorPosition280;

public class ArrayedBinaryTreePosition280 implements CursorPosition280 {

protected int currentNode;

public ArrayedBinaryTreePosition280(int pos) {

currentNode = pos;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!