Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create Javadoc for an ArrayIntStack Submit just the Javadoc html as a single fil

ID: 642899 • Letter: C

Question

Create Javadoc for an ArrayIntStack

Submit just the Javadoc html as a single file that looks good by itself (see below, do not submit index.htm).

A. Create your own Stack Class, call it ArrayIntStack.java and write four public stack methods (this is the easy part of the assignment). Use at least one private helper method. All methods in your ArrayIntStack must have O(constant) run-time. Your ArrayIntStack extends no other Classes from the Java API. Build your own data structure here!!!

1. boolean empty(); Tests if this stack is empty.
2. int peek(); Looks at the object at the top of this stack without removing it from the stack.
3. int pop(); Removes the object at the top of this stack and returns that object as the value of this function.
4. int push(int item); Pushes an item onto the top of this stack.

Since we're using int for return, you must throw an appropriate "empty" Exception for illegal peek and pop operations.

B. Generate the standard Javadoc for your class (has author, date, and all methods, each with return types plus brief descriptions) and submit just one html file : See Appendix B (Javadoc comments). Just one html file becomes the tough part of this assignment. Read on......

I require your Javadoc to have method summaries with information as listed (four methods) above, plus the header comments with author and date as shown by example below for the Iterator interface.

CAUTION: Be certain your file submitted works by itself!!! I know it looks fine on your computer, but what will it look like when I get just that one file?

You will probably need to configure your IDE to use the javadoc standard that comes with the Oracle JDK download. On my computer, the configuration path was (yours' will be slightly different): C:/Program Files (x86)/Java/jdk1.6.0_21/bin/javadoc.exe   But then I upgraded to Java7 on a 64-bit PC, and the path to javadoc changed to C:/Program Files/Java/jdk1.7.0_25/bin/javadoc.exe And maybe you've gone as far as Java8 now?

In the Iterator example above I used Java6. If you never upgraded to Java7, you're lucky, and probably done. The rest of us have now "updated" to Java7 or Java8 and it gets ugly if you're not careful, see this (BAD->): IteratorJ7.html  We have some more work to do:

Option a) Find the stylesheet reference, and change it to something like: rel="stylesheet" type="text/css" href="http://docs.oracle.com/javase/7/docs/api/stylesheet.css"

Option b) Find the stylesheet reference in you html document,   rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"

Comment out or delete that line, and go find the css file in the text/css folder. Copy that code so you have the following:

Explanation / Answer

import java.util.ArrayList; // TODO: Auto-generated Javadoc /** * The Class StackArrayList. * * @param the element type */ public class StackArrayList extends AbstractStack{ /** The data. */ protected ArrayList data; /** * Instantiates a new stack array list. */ public StackArrayList() // post: constructs a new, empty stack { StackFactory factory = new StackFactory(); data = (ArrayList) factory.getStack(); } /* (non-Javadoc) * @see Stack#push(java.lang.Object) */ public void push(E item) // post: the value is added to the stack // will be popped next if no intervening push { data.add(item); } /* (non-Javadoc) * @see Stack#pop() */ public E pop() // pre: stack is not empty // post: most recently pushed item is removed and returned { return data.remove(size()-1); } /* (non-Javadoc) * @see Stack#peek() */ public E peek() // pre: stack is not empty // post: top value (next to be popped) is returned { return data.get(size() - 1); } /* (non-Javadoc) * @see Stack#size() */ public int size() // post: returns the number of elements in the stack { return data.size(); } } // TODO: Auto-generated Javadoc /** * The Class AbstractStack. * * @param the element type */ public abstract class AbstractStack implements Stack { /** * Instantiates a new abstract stack. */ public AbstractStack(){ } /* (non-Javadoc) * @see Stack#empty() */ public boolean empty(){ return size() == 0; } }