here are the link that might need for the assignment: https://sbctc-files.instru
ID: 642608 • Letter: H
Question
here are the link that might need for the assignment:
https://sbctc-files.instructure.com/courses/1078056/files/45148695/course%20files/Chapter15/Iterator.java?download=1&inline=1&sf_verifier=ba3f1c05442c49da7b63a69529c10287&ts=1424506370&user_id=3986057
https://sbctc-files.instructure.com/courses/1078056/files/45148728/course%20files/Chapter15/Iterator.html?download=1&inline=1&sf_verifier=b7a71fc98d8a3066e1410ab15239822b&ts=1424506405&user_id=3986057
https://sbctc-files.instructure.com/courses/1078056/files/45148716/course%20files/Chapter15/IteratorJ7.html?download=1&inline=1&sf_verifier=b064df04a218ed6a2eccbe8b8091fdd6&ts=1424506420&user_id=3986057
https://sbctc-files.instructure.com/courses/1078056/files/45148727/course%20files/Chapter15/IteratorJ7css.html?download=1&inline=1&sf_verifier=a7431420203d8c2a3308fc832c9e109a&ts=1424506432&user_id=3986057
Chapter 14: Programming Project Create Javadoc for an ArraylntStack 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 ArraylntStack must have O(constant) run-time. Your ArraylntStack uses no other Classes from the Java API. Build your own data structure here!!! 1. boolean empty(); Tests if this stack is empty. 2. int peel* Looks at the object at the top of this stack without removing it from the stack. 3. int pope; 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 retum 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? Attached is a sample of the Iterator class Iteratotjava 07 from Oracle, which shows how comments are changed to produce the nice html formatted documentation in Java6 the documentation looks like: Iteratothtml ig similar to what we've been using all along. This way. the source code itself is used to generate documentation, and version control is handled really nice. 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 (x86YJavaridkl.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 FilestJavatidk1.7.0_25/biniavadoc.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: You must fix this ugly problem (or suffer loss of points) by either a) providing a ref to a live css page (maybe the oracle.com API pages), and then it gets back to pretty like this (GOOD->): :teratorJ7css.html fi?or b) putting your stylesheet inside the html, Option a) Find the stylesheet reference, and change it to something like: rel=stylesheer type=text/csshref=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=stylesheetcsstitle=StyleExplanation / Answer
A. Stack Class Program
import java.io.*;
class ArrayIntStack extends Exception
{
int st[20],top;
public ArrayIntStack()
{ top=-1;}
boolean empty()
{ boolean b;
if(top==-1)
return b;
}
int push(int item)
{ if(top==20)
{System.out.println("Stack is full");
return -1;}
else
{
st[++top]=item;
return 0;}
}
int pop()
{
int t;
if(empty()==true)
System.out.println("Stack is empty");
else
{
t=st[top];
top--;
}
return t;
}
int peek()
{ int x;
x=st[top];
return x;
}
public static void main(String args[])
{
int a,n;
ArrayIntStack ais=new ArrayIntStack();
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
do
{
System.out.println("1. Push 2. Pop 3. Peek Enter ur choice");
String s = br.readLine();
a = Integer.parseInt(br.readLine());
switch(a)
{
case 1:
try{
System.out.println("Enter any no.");
n=Integer.parseInt(br.readLine());
int x=ais.push(n);
}catch(NumberFormatException e)
{System.out.println("Invalid Input");}
break;
case 2:
try{int t=ais.pop();
System.out.println("Value deleted is " + t);
}catch(NumberFormatException e)
{System.out.println("Invalid Value");}
break;
case 3:
try{ int z=ais.peek();
System.out.println("Value peeked is: " + z);
}catch(NumberFormatException e)
{System.out.println("Invalid Value");}
break;
case 4:
System.exit(0);
}
}while(x!=4);
}
}
____________________________________________________________
B. Standard Javadoc HTML file:
/** Description of MyClass
*
* @author Anamika Pal
* @ Mar 2, 2015.
*/
public class ArrayIntStack
{
/** Description of IntFields : Array of stack st and top pointer */
public int st[20],top;
/** Constructor of ArrayIntStack class to initialize the top variable*/
public ArrayIntStack()
{ top=-1;}
/** This function checks whether the stack is empty or not*/
boolean empty()
{ boolean b;
if(top==-1)
return b;
}
/** This function is used to push an item in the stack and move the top pointer*/
int push(int item)
{ if(top==20)
{System.out.println("Stack is full");
return -1;}
else
{
st[++top]=item;
return 0;}
}
/** This function is used to pop an element from the top of the stack*/
int pop()
{
int t;
if(empty()==true)
System.out.println("Stack is empty");
else
{
t=st[top];
top--;
}
return t;
}
/** this function is used to check the item at the top of the stack*/
int peek()
{ int x;
x=st[top];
return x;
}
/** Pop and peek function throws an exception if the value returned is invalid*/
}
StyleSheets:
(a)
(b)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.