
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

- Read the dog information from the input file "Dog.txt".
- Create a new instance of the
TreeMultiSet
class to store the dogs. - Iterate over each line of the input file:
- Split the line into tag number, first name, last name, and cost.
- Create a new
Dog
object with the extracted information. - Add the
Dog
object to theTreeMultiSet
.
- Display the menu to the user.
- Enter a loop to repeat the menu until the user chooses to exit:
- Prompt the user for their choice.
- If the choice is "Show", iterate over the
TreeMultiSet
and print the names of all the dogs. - If the choice is "Add", prompt the user for dog information (tag number, first name, last name, and cost), create a new
Dog
object, and add it to theTreeMultiSet
. - If the choice is "0", exit the loop and end the program.
- If the choice is invalid, display an error message and re-display the menu.
- End the program.
Step by stepSolved in 4 steps with 7 images

- In java language Class Design – Date V0.0 & V1.0 Create a new project for this lab and create a new class inside called Date. If you created a Date class last week, you may use it as a base. What does it mean to be a Date? What data items (called “state”) do you need to keep track of? Alternatively, what does a date have? (“has a” == composition) What can a Date do? What are the actions and verbs that can be applied to a date? Come up with one or two. These become the class’s methods. Try adding 3 data items to your Date to manage the month, day and year. Should these be local variables? Class-level (or instance) variables? Now let’s build a method to set the date This function should take 3 integers as input and assign these to your instance variables declared in the previous step. public void setDate(int m, int d, int y) { And, let’s build a method to report the date This function takes no input and uses the console to output the Date in the format…arrow_forwardThis is an incomplete code. Where are the implementations for each method you mentioned in the comments? I need the implementation logic (code) for each method you mentioned in the comments. Please include the code implementation logic for each method instead of the comments.arrow_forwardCreate a new project named lab10. You will be implementing two classes: A SolarSystem class, and a Planet class. The SolarSystem contains Planet objects stored in a vector. A UML diagram for the Solar System and Planet classes The first part you should implement is the Planet class. Don't add the SolarSystem files to the project at the beginning, just work on the Planet class. Test the different overloaded operators as we did during lecture for your Planet class, and then move on to the SolarSystem class. The SolarSystem default constructor should resize the vector to zero. The default constructor values for Planet can be whatever you’d like, but make the mass a very small number, so later on when you're looking for the largest planet, it doesn't use the default Planet value. The addPlanets() method will take a number as an argument for the number of Planets that will be in your SolarSystem. So if you call addPlanets with 5 as an argument, there will be 5 Planets to add to the…arrow_forward
- In C++ programarrow_forwardMUST BE IN JAVA. PLEASE USE COMMENTS AND WRITE THE CODE IN SIMPLEST FORM.arrow_forwarduse Pyhton. The tossball simulation we developed together in class is attached to this week's notes. Study it carefully to understand exactly what it is doing. It currently launches a ball in the main graphics window. You need to make the following changes and improvements and send me at the end your finished project in zipped folder format. Only python modules should be included. 1) Add a new class named "Cannon". This class it to represent the cannon that launches the balls. It should draw a rectangle (hint: use Polygon class from Graphics.py) at the launch point. Its width should be equal to the diameter of the balls that it shoots out and its length should be proportional to the speed, say something like speed * 0.15. The cannon should also be directed in the same direction that the balls shooting. Add proper width, height, and angle attributes to the class for supporting the settings above. The balls should start from the bottom of the cannon and be projected out through the…arrow_forward
- I need a code that demonstrates the use of the below items (Templates, overloading, and vectors). It doesn't need to be special and you can choose the example for the code. Maybe 30 - 50 lines of code that I can run in Visual Basic 2019. I just want to be able to compile it so that I understand what I am reading next week. Working examples are better than what I can pull from the single code examples in the book. Please label to help me identify. Thanks 1. Write C++ code (perhaps around 30-50 lines of code) and make it compile and run showing how to use: a. Templates b. Overloading c. Vectorsarrow_forwardCreate a new project named lab7_1. You will be implementing a Tacos class. For the class attributes, let’s use to type of taco, number of tacos, and price. Note that the price per taco of any type is 99 cents. Therefore, allow the taco type and number of tacos to be set directly, but not the price! The price should be set automatically based on the number of tacos entered. So a good idea may be to call the setter for the price inside the function that sets the number of tacos. Some other requirements: A default constructor and a constructor with parameters for your taco type and number of tacos member variables. You should also include setters and getters for these private member variables. However, make sure that the setter for price is private! You don’t want anyone outside the class modifying price. This setter should be called anytime you change the number of tacos. Your constructor needs to call a set method that allows you to set the two member variables, thus takes two…arrow_forwardPlease help with the following question: In Java without using arrays, Integer.parseInt in the main class or this.keyword in the classes code the following. Make 1 project having 1 main class and 3 other classes. For each classes you need make to use the constructor to set its attributes. Your classes have to have setters and getters and their attributes should all be private. Make a class University A university name (string)A university population (int)A university budget(double) Make a class Department An ID(int)A Name(string)A DEP ID(int) Make a class Student Dep Name(string)Dep ID(int) In the main class first Create three departments.Ask the user to input the field values. In the main class create 5 students. Ask the user to input the field values. Write a function in the main class that takes two integers as input and Checks if they are equal. Use that function to check if for a department and a student their DEP ID is equal. (So you have to check if dep1.di=student1.id for…arrow_forward
- Guide to working through the project Steps: Write the GradeBook constructor that reads student information from the data file into the ArrayList roster). For now, ignore the grades. Test your GradeBook class before proceeding to the next step. Create the Grade class. Test your Grade class before proceeding to the next step. Modify the Student class to include an ArrayList of Grade. Test the Student class before proceeding to the next step. Finish writing the GradeBook constructor to process the grades as they are read in from the data file. Test the GradeBook class before proceeding to the next step. Add additional functionality to the GradeBook and Student classes one method at a time. Here is Grade.jave code is shown below. public class Grade { // TODO: complete this class as described in this task write-up } GradeBook Class The GradeBook class has a single instance variable roster, an ArrayList of Student. This class performs all operations related to the scores of all…arrow_forwardIN JAVA PLEASEarrow_forwardJava Programming Please help me with this Java Progamming project NOT GRADED. Practice homework Please comment the code well and organize the classes so I can understand. Thank you! If solution if the one that is desirable, I will upvote! I really appreciate this, Bartleby! Waiting Times should not be negative. You sent back a solution but the waiting time was negative and that was incorrect. Please take your time and help me with this.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





