Question: Use Java LinkedList to store data in the desired order. Please create a package name hmFour under your HM project in eclipse. Required Files coins.txt

Use Java LinkedList to store data in the desired order. Please create a package name hmFour 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 LinkedList (10 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 StoreCoinLinkedList class. You do not create the main method in the StoreCoinLinkedList.
  3. Edit StoreCoinLinkedList and create LinkedList field, which can hold Coin type data.

private LinkedList list = new LinkedList();

  1. You need to use your homework 1 code in a method inside StoreCoinLinkedList to read coin data from coins.txt file, and then create a Coin Object for each coin and add created coins to LinkedList when the constructor is called for StoreCoinLinkedList.
  2. Then, write four methods called findMin, findMax, searchName, and size in StoreCoinLinkedList.
    1. findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the list.
    2. findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the list.
    3. searchName method takes a name as String and returns true or false whether the name of the Coin exists in the list.
    4. size method returns int that shows how many Coin in the list.

  1. Use the Junit test to test your four methods of StoreCoinLinkedList are correct for different cases.

Task #2 Store coin data in a LinkedList in the price order (10 pts)

  1. Create another class named StoreCoinLinkedListOrdered class. You do not create the main method in the StoreCoinLinkedListOrdered.
  2. Edit StoreCoinLinkedListOrdered and create LinkedList field, which can hold Coin type data.

private LinkedList list = new LinkedList();

  1. You need to use your homework 1 code in a method inside StoreCoinLinkedList to read coin data from coins.txt file, and then create a Coin Object for each coin and insert created coins to LinkedList based on USD price when the constructor is called for StoreCoinLinkedList. Therefore, the lowest price will be at the beginning, and the largest price will be the last element in the list (increasing order of coins based on price). If you know how to use Java Comparable for Coin Object, you can use it.
  2. Then, write four methods called findMin, findMax, searchName, and size in StoreCoinLinkedListOrdered.
    1. findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the list. Important: what is the price of the first element?
    2. findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the list. Important: what is the price of the last element?
    3. searchName method takes a name as String and returns true or false whether the name of the Coin exists in the list.
    4. size method returns int that shows how many Coin in the list.

  1. Use the Junit test to test your four methods of StoreCoinLinkedListOrdered are correct for different cases.

Task #3 Submit

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

coins.txt

{"Label":"$AAPL/BTC","Name":"$aapl","Price_btc":0.00032184,"Price_usd":3.92754931,"Price_cny":25.24580546,"Price_eur":3.31668630,"Price_gbp":3.01284982,"Price_rur":299.41224541,"Volume_24h":0.00000000,"Timestamp":1603273440},{"Label":"YEET/BTC","Name":"$yeet","Price_btc":0.00078805,"Price_usd":10.74434998,"Price_cny":72.57942864,"Price_eur":9.23529314,"Price_gbp":8.33139810,"Price_rur":856.31640156,"Volume_24h":0.00000000,"Timestamp":1604353440},{"Label":"007/BTC","Name":"007coin","Price_btc":0.00003637,"Price_usd":0.48785974,"Price_cny":3.28000444,"Price_eur":0.41277066,"Price_gbp":0.37519473,"Price_rur":37.19817970,"Volume_24h":0.00000000,"Timestamp":1603802520},{"Label":"ZOC/BTC","Name":"01coin","Price_btc":0.00000015,"Price_usd":0.00428709,"Price_cny":0.02668907,"Price_eur":0.00350714,"Price_gbp":0.00315430,"Price_rur":0.30346770,"Volume_24h":0.64014656,"Timestamp":1609432800},{"Label":"ZCH/BTC","Name":"0cash","Price_btc":0.00000001,"Price_usd":0.00028580,"Price_cny":0.00177927,"Price_eur":0.00023380,"Price_gbp":0.00021028,"Price_rur":0.02023118,"Volume_24h":0.00024462,"Timestamp":1609432800},{"Label":"ZCN/BTC","Name":"0chain","Price_btc":0.00001281,"Price_usd":0.36611765,"Price_cny":2.27924666,"Price_eur":0.29951006,"Price_gbp":0.26937801,"Price_rur":25.91614229,"Volume_24h":1.56004987,"Timestamp":1609432800},{"Label":"ZRX/BTC","Name":"0x","Price_btc":0.00001246,"Price_usd":0.35611443,"Price_cny":2.21697216,"Price_eur":0.29132672,"Price_gbp":0.26201796,"Price_rur":25.20805097,"Volume_24h":879.17034113,"Timestamp":1609432800},

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!