Question: In java create a class called AvailableTravelers that does the following: 1. A class contains the Traveler object available for travel (Traveler class is an

In java create a class called "AvailableTravelers" that does the following:

1. A class contains the Traveler object available for travel (Traveler class is an abstract class)

2. Instance variables 1. travelers - a collection of Traveler objects. 2. numOfTravelers number of travelers in the collection (partially filled array value)

3. Methods 1. Default constructor 1. creates array to a size of 20 and 2. sets numOfTravelers to 0.

2. Parametrized constructor 1. Creates array and sets its size to the value of a parameter representing the capacity. 2. sets numOfTravelers to 0.

3. public boolean addTraveler(Traveler t) 1. adds the given Traveler to the array. 2. Increments numOfTravelers 3. returns false if the Traveler is already in the arry (test by ID) or the list is at capacity, 4. returns true if Travleler successfully added to array. 4. public Traveler findTravelerByName(String name) 1. returns the Traveler with the given name 2. null if not found. 5. public String toString - return a nicely formatted String (see below) that represents each traveler in the array. (hint call the toString on each Travelers object in the array)

Crew [name=Klaes Ashford, id=3, current=BELT, position = Captain, flight hours = 6728]

Passenger [name=Klaes Ashford, id=3, current=BELT, seat=FIRST, cost = $1499.99, rewardsPoints = 3459]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!