Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can i give these two classes javadoc?? public class stackDriver { public static void main(String[] args) { StackInterface strStack = new ArrayStack (); StackInterface

How can i give these two classes javadoc??

public class stackDriver {

public static void main(String[] args) {

StackInterface strStack = new ArrayStack();

StackInterface dogStack = new ArrayStack();

Player player = new Player("Rex");

player.setScore(29);

strStack.push(player);

player = new Player("Christy");

player.setScore(13);

strStack.push(player);

player = new Player("Zane");

player.setScore(31);

strStack.push(player);

player = new Player("Cali");

player.setScore(39);

strStack.push(player);

Dogs dog = new Dogs("rooney");

dog.setAge(10);

dog.setBreed("Golden");

dogStack.push(dog);

dog = new Dogs("Christy");

dog.setAge(7);

dog.setBreed("Golden");

dogStack.push(dog);

dog = new Dogs("Zane");

dog.setAge(2);

dog.setBreed("Golden");

dogStack.push(dog);

dog = new Dogs("Cali");

dog.setAge(5);

dog.setBreed("Golden");

dogStack.push(dog);

// display the original stack

System.out.println("Original stack of players:");

System.out.println(strStack);

// display number of elements in stack

System.out.println("Current number of players in the stack: "+strStack.size());

// display current top player of stack

System.out.println(" Current player on top of stack:");

System.out.println(strStack.peek());

// pop first 2 elements of stack

strStack.pop();

strStack.pop();

// display updated stack elements

System.out.println(" Altered stack of players:");

System.out.println(strStack);

// display number of elements and player at top of stack

System.out.println(" Current number of players in the stack: "+strStack.size());

System.out.println(" Current player on top of stack:");

System.out.println(strStack.peek());

// check if stack is empty

System.out.println(" Stack empty (true or false): "+strStack.isEmpty());

// loop to empty the stack

while(!strStack.isEmpty())

strStack.pop();

// display number of elements in stack and if stack is empty

System.out.println(" Current number of players in the stack: "+strStack.size());

System.out.println(" Stack empty (true or false): "+strStack.isEmpty());

System.out.println();

System.out.println("---------------------------------------------------");

System.out.println("Original stack of players:");

System.out.println(dogStack);

// display number of elements in stack

System.out.println("Current number of players in the stack: "+dogStack.size());

// display current top player of stack

System.out.println(" Current player on top of stack:");

System.out.println(dogStack.peek());

// pop first 2 elements of stack

dogStack.pop();

dogStack.pop();

// display updated stack elements

System.out.println(" Altered stack of players:");

System.out.println(dogStack);

// display number of elements and player at top of stack

System.out.println(" Current number of players in the stack: "+dogStack.size());

System.out.println(" Current player on top of stack:");

System.out.println(dogStack.peek());

// check if stack is empty

System.out.println(" Stack empty (true or false): "+dogStack.isEmpty());

// loop to empty the stack

while(!dogStack.isEmpty())

dogStack.pop();

// display number of elements in stack and if stack is empty

System.out.println(" Current number of players in the stack: "+dogStack.size());

System.out.println(" Stack empty (true or false): "+dogStack.isEmpty());

System.out.println();

try {

System.out.println("Creating first stack , to track players");

System.out.println("Peeking at top of stack 1");

strStack.peek();

} catch (StackException e) {

System.out.println(e);

}

System.out.println(strStack.isEmpty());

}

}

public class Dogs {

private String dogName;

private int age;

private String breed;

public Dogs () {

this.dogName = "";

this.age = 0;

this.breed = "";

}

public Dogs (String name) {

this.dogName = name;

}

//accessors

public String getName() { return dogName;}

public int getAge() {return age;}

public String getBreed() { return breed;}

//mutators

public void setName(String name) { this.dogName = name;}

public void setAge(int age) { this.age = age;}

public void setBreed(String breed ) { this.breed = breed;}

public String toString()

{

return("Name: " + getName()

+ " Breed:" + getBreed() + " Age: "

+ getAge());

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

List the seven broad principles of internal control.

Answered: 1 week ago