Road trip time! You and your friends load up in your friend’s minivan and drive across the country! You need to keep track of the people in the vehicle as well as the states that each person has...

1 answer below »

Road trip time! You and your friends load up in your friend’s minivan and drive across the country! You need to keep track of the people in the vehicle as well as the states that each person has visited in their life.



----------------



Important: Although this is a Partner assignment, each student must submit their own copy -- not doing this will result in a grade of zero. Working with a partner is optional. If you do choose to work with a partner, please specify their name when submitting your assignment.



-----------------



Requirements:


For a safe and successful road trip you must:



  • Store all of your passengers’ names and contact info.

  • Maintain a map of which states each passenger has visited.



-----------------



All of your classes should be properly encapsulated, follow all proper coding conventions discussed to date, and be logically constructed following good Object Oriented design. Your submitted code should compile and run without errors.



-----------------


Step 1: Your Passenger Class



  • Create a Passenger class that stores the passenger’s First Name, Last Name, and Phone Number as attributes.

  • Override toString(), equals(), and hashCode() as discussed in class. First Name and Last Name are sufficient to uniquely identify a passenger.

  • Create any getters and setters that are necessary.



Step 2: Your RoadTrip Class



  • Create a RoadTrip class that stores the minivan’s nickname, a HashSet of Passenger objects (to represent who is riding in the minivan), and a HashMap that stores the set of states visited by each Passenger. Note that you may use either the passenger’s name or a Passenger object as the key to your HashMap, but using the passenger's name is much easier!

  • Create a “addPassenger” method that adds a Passenger to the HashSet of passengers riding on the trip. Since the minivan can seat a maximum of 8 people, your addPassenger method should limit the number of passengers to 8 and display a “minivan full” message if the user attempts to add a passenger once the minivan is full. Return a boolean value of true if successful or false if unsuccessful.

  • Create a “displayPassengers” method that displays all the information about each passenger in the minivan using Iterators as demonstrated in class.

  • Create a “addStateVisited” method that takes a Passenger object and a state name as parameters, and adds that state to the HashMap of states that have been visited by that passenger.

  • [EDIT] Create a "getStatesByName" method that takes a passenger name as a parameter and returns the set of states visited by that passenger.

  • Create a “displayStatesVisited” method that displays the names of everyone in your HashMap and all of the states that they have visited. Use Iterators as shown in class.



Step 3: Your main method



  • In your main method, repeatedly prompt the user to add up to 8 passengers or type “quit” once they are finished adding passengers. Use the addPassenger method of your RoadTrip class to accomplish this.

  • Next, repeatedly prompt the user to add information about which passenger has visited which state or type “quit” once they are finished these records.

  • Next, repeatedly prompt the user to type in the person’s name that they would like to see all visited states for, or “quit” once they are done.

  • Finally, call your displayPassengers method to display all information about all passengers.



Step 4: Create a UML Class diagram for all of your entity classes. Use the three-box structure shown in class and indicate the data type of each attribute. Use appropriately-labelled arrows to show relationships.

Answered Same DayOct 29, 2021

Answer To: Road trip time! You and your friends load up in your friend’s minivan and drive across the country!...

Saima answered on Oct 30 2021
114 Votes
RoadTrip/.classpath

    
        
            
        
    
    
    
RoadTrip/.project

     RoadTrip
    
    
    
    

        
             org.eclipse.jdt.core.javabuilder
            
            
        
    
    
        ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here