Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java You are working on part of a software system for a small airline, FCSAir. This airline uses small planes that have strict weight

in java

image text in transcribedimage text in transcribed

You are working on part of a software system for a small airline, FCSAir. This airline uses small planes that have strict weight limits. Your responsibility is to write two classes, one called Passenger and one called Plane. The Passenger class contains instance data for: The passenger's name A unique id for the passenger (which is automatically assigned) The passenger's weight (in kg) The weight of the passenger's luggage (in kg) Each of the instance data requires an accessor method. A mutator method is needed to set the weight of the passenger's luggage to a new value. Each passenger should also be automatically assigned a unique identification number when it is created. These id numbers should be assigned in order starting at 1000 and cannot be changed once assigned. The Plane class manages the passengers it holds, up to a maximum number passed in to the constructor. The weight limit of the plane (in kg) is also passed in to the constructor. This class needs to accomplish the following: 1. Add a passenger to the plane, returning true or false to indicate if the passenger is successfully added. A passenger can be added to the plane only if three conditions are met: a) the plane is not full; b) the passenger to be added would not put the plane over its weight limit (including the passenger's personal weight and the weight of their luggage); c) the passenger is not already on the plane. Once a passenger is added the total weight of all passengers is updated. 2. Remove a passenger from the plane, returning true or false to indicate if the passenger has been removed. A passenger can only be removed if they are already on the plane. Once a passenger is removed, the total weight of all passengers is updated. 3. Change the weight of the luggage of a passenger who is already on the plane's list, returning true or false to indicate if the luggage weight of the passenger has been updated. This method is passed separately the passenger object to be changed and the new weight of their luggage. The weight of a passenger's luggage can only be changed if a) the passenger is on the plane's list and b) the update to the luggage weight would not put the plane over its weight limit. If the passenger's luggage weight is updated, the total weight of all passengers is also updated. 4. Report the remaining weight that is still available on the plane (weight limit - total passenger weight). 5. Retrieve a textual passenger list, formatted in tab-separated columns, showing the id, name and personal weight + luggage weight, as shown in this example: 1000 Fred 1001 Martha 1002 Susan Total weight: 112.50 kg 043.30 kg 093.00 kg 248.80 kg Notes: The order of passengers on the passenger list is not important (use this information to make sure you add and remove passengers in the most efficient manner) You must use arrays to store passengers in the Plane class. Data structures other than arrays (e.g. ArrayLists, Vectors, Linked Lists, etc.) are not permitted on this assignment. Passengers are identified by their id when searching though the list of passengers You may find it helpful to create a helper method to return the position of a passenger in the list. Driver program for testing: Write a driver program to test the Passenger and Plane classes, covering the following: Add a small number of passengers. Try to add a passenger that would put the plane over its weight limit. . Try adding a passenger already on the plane. . Try to add a passenger that would put the plane over its passenger limit (but not the weight limit). Change the weight of the luggage of a passenger on the list, for cases where the new weight would and would not put the plane over its weight limit. . Try to remove a passenger, for cases where the passenger is on the plane and also for cases where the passenger is not on the plane. Report the remaining weight available on the plane (format the output the same as the values in the passenger list). Print a passenger list. In your report you must describe each test case, and show the effects on the passenger list and total weight after each of the operations described above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions