Question: Done in Java Task #1 Store coin data in a LinkedList (10 pts) Create a Coin class that represents each coin information with attributes inside
Done in Java
Task #1 Store coin data in a LinkedList (10 pts)
- 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.
- Create another class named StoreCoinLinkedList class. You do not create the main method in the StoreCoinLinkedList.
- Edit StoreCoinLinkedList and create LinkedList field, which can hold Coin type data.
private LinkedList
- 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.
- Then, write four methods called findMin, findMax, searchName, and size in StoreCoinLinkedList.
- findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the list.
- findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the list.
- searchName method takes a name as String and returns true or false whether the name of the Coin exists in the list.
- size method returns int that shows how many Coin in the list.
- 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)
- Create another class named StoreCoinLinkedListOrdered class. You do not create the main method in the StoreCoinLinkedListOrdered.
- Edit StoreCoinLinkedListOrdered and create LinkedList field, which can hold Coin type data.
private LinkedList
- 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.
- Then, write four methods called findMin, findMax, searchName, and size in StoreCoinLinkedListOrdered.
- 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?
- 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?
- searchName method takes a name as String and returns true or false whether the name of the Coin exists in the list.
- size method returns int that shows how many Coin in the list.
- Use the Junit test to test your four methods of StoreCoinLinkedListOrdered are correct for different cases.
text file: https://learn-us-east-1-prod-fleet02-xythos.content.blackboardcdn.com/5cd03868094b1/7953000?X-Blackboard-Expiration=1613422800000&X-Blackboard-Signature=Q8%2FhXbQXiGvm2y2GbDKdXYPlUdQxKP6lvq9%2FJmuRbQw%3D&X-Blackboard-Client-Id=200124&response-cache-control=private%2C%20max-age%3D21600&response-content-disposition=inline%3B%20filename%2A%3DUTF-8%27%27coins%25282%2529.txt&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210215T150000Z&X-Amz-SignedHeaders=host&X-Amz-Expires=21600&X-Amz-Credential=AKIAZH6WM4PL5SJBSTP6%2F20210215%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=0cacf9f1ea4543aad36081182b346192fdb59e79a799633cbf9a48267578cb12
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
