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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Working with TreeMultiSet and MultiSets

*In Java only*. I'm learning about the topics below and would love to see this program created so that I can get a better understanding for a later project. Please keep the class names the same as below and do not comment the code. I want to try and figure it out. 

 

You will have 4 different classes (please keep them separated as best as possible/use names provided below for classes):

  1. 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.

  2.  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.

  3.  Dogs class needs to implement Comparable on tagNumber

  4. 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 :

  1. Show (this lists all the names)

  2. 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

Expert Solution
Step 1: Program Approach
  1. Read the dog information from the input file "Dog.txt".
  2. Create a new instance of the TreeMultiSet class to store the dogs.
  3. 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 the TreeMultiSet.
  4. Display the menu to the user.
  5. 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 the TreeMultiSet.
    • 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.
  6. End the program.
steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY