Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please using a linked list to do ListStack only. Thanks Your Stack implementations will be used to do sound manipulation, namely reversing a sound clip.

Please using a linked list to do ListStack only. Thanks

Your Stack implementations will be used to do sound manipulation, namely reversing a sound clip. This process, called backmasking, was used by musicians including the Beatles, Jimi Hendrix, and Ozzy Ozbourne. You will write a program that reads a sound file in the .dat format and writes another .dat sound file which is the reverse of the first. The sample code provides a class Reverse whose main method reads in a .dat sound file, pushes all the sound values on a stack, then pops them all off and writes them into a new .dat sound file. The sample code has also provided an interface DStack, which defines a stack that holds double values. Your first job is to familiarize yourself with these files.

You need to provide two stack implementations, one using an array and one using a linked list. They should be called ArrayStack and ListStack, respectively. They should implement the DStack interface given to you. Reverse should work and create backward sound files once you complete these two implementations. Your array implementation should start with a small array (say, 10 elements) and resize it to create an array twice as large whenever the array becomes full, copying over the elements from the smaller array. While there are convenient Java library methods for copying arrays, for this assignment use your own loop to copy array elements manually (so you can see the work involved in copying). Both ArrayStack and ListStack should throw an EmptyStackException if pop() or peek() is called when the stack is empty. To use EmptyStackException, add the following line to your file: import java.util.EmptyStackException; The only Java class that you should use to complete the implementations of your stacks is java.util.EmptyStackException. You should also use the length field of an array.

DStack.java /** * Interface for a stack of primitive doubles. * * NOTE: You will * need to write something better for your implementations. */ public interface DStack { /** * is empty? */ public boolean isEmpty(); /** * push */ public void push(double d); /** * pop * @return the deleted value * @throws EmptyStackException if stack is empty */ public double pop(); /** * peek * @throws EmptyStackException if stack is empty */ public double peek(); }

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

annaul report

Answered: 1 week ago