Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Java) We have already used the stack ADT to design a test program. Since ADTs are not concerned about HOW the inner workings are designed

(Java) We have already used the stack ADT to design a test program. Since ADTs are not concerned about HOW the inner workings are designed and implemented, if we use the same interface, we should be able to use the same exact code for the test cases we developed for the previous assignment if we re-declare all the objects used to a different implementation of the stack ADT that uses linked nodes instead.

The stack ADT can also be leveraged to greatly simplify any program that requires a collection of items where operations only occur on one end. It is a great ADT choice simulating any card game where you have a collection of cards that uses a first in, first out behavior.

Part 1: implement your own version of the stack ADT using linked nodes. Implement all necessary public methods according to the interface. Additionally, override the toString method.

Part 2: design and implement a simple pokemon card game.In the game, the player gets 10 random cards and the computer gets random 10 cards - which are then stored in stacks.

Each card's information should be imported from the pokemon.csv file.

In each round, the player and computer's top card in the stack will be compared.

If the player's pokemon's attack value is greater than the computer's pokemon's defense value, then player wins the round and gets a point.

At the end of the 10 rounds, display how many points the player earned.

public interface Stack {

/** Adds a new entry to the top of this stack.

@param item An object to be added to the stack.

@throws IllegalStateException - if the element cannot be added at this time due to capacity restrictions */

public void push (T item) throws IllegalStateException ;

/** Removes and returns this stack's top entry.

@return The object at the top of the stack.

@return null if the stack is empty */

public T pop();

/** Retrieves this stack's top entry.

@return The object at the top of the stack.

@return null if the stack is empty */

public T peek();

/** Detects whether this stack is empty.

@return True if the stack is empty. */

public boolean isEmpty();

/** Retrieves the number of entries in this stack.

* @return number of entries. */

public int length();

}

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_step_2

Step: 3

blur-text-image_step3

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions