Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is java Client . You'll now write a client program called FSclient.java. It should use (and test) your implementations of the two classes above.

This is java

Client. You'll now write a client program called FSclient.java. It should use (and test) your implementations of the two classes above. Your code should work like the Unit Test from the ResizingArrayStack from Lab2, so that it takes a sequence of tokens like:

 to be or not to - be - - that - - - is 

treating non-dash tokens as "push" requests, and dash characters as pop requests. It should run like:

 % java-alg4 FSclient 4 < tobe.txt 

The result of such a command should be (a) the stack is limited to size 4, so it should never contain more than 4 items, and (b) on each pop request, the popped term should be printed. You may use the main function from ResizingArrayStack as a guide:

public static void main(String[] args) { ResizingArrayStack stack = new ResizingArrayStack(); while (!StdIn.isEmpty()) { String item = StdIn.readString(); if (!item.equals("-")) stack.push(item); else if (!stack.isEmpty()) StdOut.print(stack.pop() + " "); } StdOut.println("(" + stack.size() + " left on stack)"); } 

Once you have implemented it, test with several input files, to ensure that it is working as expected. How does it deal with pop requests on an empty stack? You may find it useful to test the contents of the FS-stack after each action, using its iterator.

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: 3

blur-text-image

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions