Create a program that maintains a list of dogs (provided below in txt file). Begin by reading the file (below named Dog.txt), create a Dog object for each part of the file and load the Dog object into the MultiSet. Note that if the Dog object already exists In MultiSet, then the program will increment the value of the count for that Dog object. Then continue by showing the menu below and asking for user input.
Working with TreeMultiSet and MultiSets
*In Java only*. I'm learning about the topics below and would love to see this
You will have 4 different classes (please keep them separated as best as possible/use names provided below for classes):
-
Multiset class: Make a multiset interface that does not extend anything. public interface MultiSet<AnyType> Test the MultiSet by adding Strings and test if duplicates are counted.
-
TreeMultiSet class: It implements MultiSet but does not extend. Use private TreeMap<AnyType, Integer> map; (to look for any duplicates) override toString in the TreeMultiSet class.
-
Dogs class needs to implement Comparable on tagNumber
-
Test class (has main method and methods for the menu) This has the menu and asks for the user input.
Instructions:
Create a program that maintains a list of dogs (provided below in txt file). Begin by reading the file (below named Dog.txt), create a Dog object for each part of the file and load the Dog object into the MultiSet. Note that if the Dog object already exists In MultiSet, then the program will increment the value of the count for that Dog object. Then continue by showing the menu below and asking for user input.
Create a menu with the details below :
-
Show (this lists all the names)
-
Add (ask the user for dog information and add to the multiset)
0. Exit
Create a loop that reshows the menu so that the user can choose again until 0 is chosen for exit.
Use Dog.txt (below) The fields are (from left to right)
tagNumber(string), First name(string), Last name(string), Cost(double)
_________________________________________________________________________
342, Baxter, Ken, 53.50
341, Cooper, Doo, 2005
654, Duke, Hills, 9999.9
356, Elvis, Yoda, 2500
786, Kermit, Toast, 5557
435, Picasso, Prints, 444.09
223, Puck, Net, 298
765, Rocket, Springer, 850
943, Ziggy, Chills, 20.034
239, Arya, Lib, 3456
837, Cassidy, Hansel, 564
Step by step
Solved in 4 steps with 7 images