Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Done in Java. Please help! Use Java Stack to store data in the desired order. Please create a package name hmFive under your HM project

Done in Java. Please help!

Use Java Stack to store data in the desired order. Please create a package name hmFive under your HM project in eclipse.

Required Files

  • coins.txt

Those data are obtained from worldcoinindex.com API. It includes one long line text inside it, which has values of all cryptocurrencies. Please do not modify the coins.txt file.

Task #1 Store coin data in a Stack (15 pts)

  1. Create a Coin class that represents each coin information with attributes inside { and } in the coins.txt file. Make sure that all fields are private and use getter and setter methods to access and modify the fields of Coin. You can use your homework 3 code.
  2. Create another class named StoreCoinStack class. You do not create the main method in the StoreCoinStack.
  3. Edit StoreCoinStack and create a Stack field, which can hold Coin type data.

private Stack stack = new Stack();

  1. You need to use your homework 1 code in a method inside StoreCoinStack to read coin data from coins.txt file, and then create a Coin Object for each coin and add created coins to the stack when the constructor is called for StoreCoinStack.
  2. Then, write five methods called findMin, findMax, searchName, size, and remove in StoreCoinStack. While you implement those methods, you can only use five methods in Stack; pop, push, peek, empty, and search. You cannot use any inherited methods from Vector to Stack. Do not forget, search in Stack use the equals method for searching, to use it, you need to override the equals method for Coin Object based on your need.
    1. findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the stack.
    2. findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the stack.
    3. searchName method takes a name as String and returns true or false whether the name of the Coin exists in the stack.
    4. size method returns int that shows how many Coin in the stack.
    5. remove method takes two inputs; field and value, as Strings and removes only the coin or coins from the stack if field: value matches with the coin, and return the removed coins in another Stack. Think of the removing method as a filter.
  3. Use the Junit test to test your four methods of StoreCoinStack are correct for different cases.

Task #2 Submit

  1. Submit java source files for Coin, StoreCoinStack, and Junit test cases
  2. Submit a text file containing runtimes of five methods in StoreCoinStack in terms of Big-O. Make sure that you take into account the runtimes of Stack methods while you analyze your methods.

Coins.txt file: https://drive.google.com/file/d/150hp232orM7aOkOa4qS12je27UBML342/view

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

More Books

Students also viewed these Databases questions