Computer Science Homework Help

University of Massachusetts Boston Collections API Task

 

  1. Collections API Choose the appropriate container class to use for the tasks below from our collection classes. Use the simplest one that has the power you need. Assume that in increasing complexity they are: List<T>, Set<T>, PriorityQueue<T>, Map<K,V>
  • You are writing a system for car rental business. For each (unique) category string, like “economy” or “full-sze” you need fast access to the collection of cars available, and for each, their make and model and capacity. Element type Car: simple Java class, with private instance variables int carId, String make, String model, int capacity, with a constructor, and getters and setters for the id, make, model and capacity. To keep the cars moving, you need to keep this collection in order of last rental turn-in time.

container: choose one for a collection of cars and fill in type(s):

List <______>, Map < ______ , ______>, Set <_____>, PriorityQueue <_____>

How to create one such container, using this type

  1. b. In the same scenario, now consider how to look up the collection of cars you defined in part a. for category “economy” or “full-size”.
  2. c. Consider rented cars out on the road. Each has a carId, and an expected return time (Date) in a RentedCar simple Java class. We want to simulate the future return of each car based on its stated return time to predict how many cars we will have available in each category in the future. Using statistical analysis, we can generate future rentals for the system. How can we hold the RentedCar objects to be able to run this simulation, drawing out the next event, the return of a car? Assume RentedCar has an appropriate compareTo method.

container: choose one to support lookup of a collection of cars by category string and
fill in type(s):

List <______>, Map < ______ , ______>, Set <_____>, PriorityQueue <_____>

How to create one such container, using this type:

container: choose one to hold RentedCar objects for this purpose and fill in type(s):

List <______>, Map < ______ , ______>, Set <_____>, PriorityQueue <_____>

How to create one such collection, using this type: