Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program all of this question in java please and thank you . Do all of this in java please and thank you. The purpose of

Program all of this question in java please and thank you .

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Do all of this in java please and thank you.

The purpose of this assignment is to: Review classes and objects and partially filled arrays. Important habits to develop for all assignments: Start each assignment early so you have time to ask questions if / when you encounter problems. When working on the computer, save your work early & often. Include Javadoc for each program that you write (for drivers only your name and student number beside the @author tag in a Javadoc comment block at the top of the driver class is required). Run the Javadoc utility on your classes to ensure there are no errors in your comments (the documentation files created from running the Javadoc utility only need to be submitted with the assignment when specified): javadoc -author-private FileName.java Don't forget to make a back-up copy of your work somewhere other than on your computer (e.g.: on a USB key, external hard drive, or cloud drive). Loading a Ferry You are writing software to manage the booking system for small ferries which carry a small number of vehicles and the passengers in the vehicles (the ferries do not allow pedestrians). The drivers of the vehicle must pre-book their crossing in advance. The booking system must adhere to restrictions on the total number of vehicles and total number of axels allowed on a ferry, and weight limits. Each ferry also has a restriction on the number of passengers allowed on the ferry. You will need to write two classes, one called Vehicle and one called Ferry. The Vehicle class contains instance data for: . A unique ID for the vehicle (automatically assigned) The number of passengers in the vehicle (the driver is included in this count) The number of axels (this is the number of pairs of wheels i.e.: a car has 2 axels, a car towing a trailer has 3 axels, transport trucks can have even more axels i.e.: 3, 4, 5 etc.) Weight of the vehicle (in kg) Each of the instance data requires an accessor. A mutator is needed to set the number of passengers in a vehicle to a new value. Each vehicle should also be automatically assigned a unique identification number when it is created. These ID numbers should be assigned in order, starting at 100. The Ferry class manages the vehicles it holds. The following information is passed in to the constructor: The maximum number of vehicles allowed on the ferry. The maximum number of axels allowed on the ferry. The maximum number of passengers allowed on the ferry. The weight limit of the ferry (in kg). This class needs to accomplish the following: 1. Add a vehicle to the ferry, returning true or false to indicate if the vehicle is successfully added. A vehicle can be added to the ferry provided that it doesn't exceed the maximum number of vehicles, and only if all of the following additional conditions are met: a) the vehicle to be added would not put the ferry over its weight limit; b) the vehicle to be added would not put the ferry over its passenger limit; c) the vehicle to be added would not put the ferry over its axel limit; and d) the vehicle is not already on the ferry. Once a vehicle is added the total weight of all vehicles, total number of passengers, and total number of axels must be updated. 2. Remove a vehicle from the ferry, returning true or false to indicate if the vehicle has been removed. A vehicle can only be removed if it is already on the ferry. Once a vehicle is removed, the total weight of all vehicles, total number of passengers, and total number of axels must be updated. 3. Change the number of passengers in a vehicle that is already on the ferry, returning true or false to indicate if the number of passengers has been updated. The number of passengers in a vehicle can only be changed if a) the vehicle is already on the ferry and b) the change in the number of passengers would not put the ferry over its passenger limit. If the number of passengers in a vehicle is updated, the total number of passengers is also updated. 4. Report the weight that is still available on the ferry (weight limit - total vehicle weight). 5. Retrieve a textual vehicle list, formatted in tab-separated columns, showing the ID and weight of the vehicle. At the end of the list print the total weight, total number of axels, and total number of passengers, as shown in this example: 100 01,524.75 kg 101 30, 480.50 kg 102 27,130.00 kg Total Weight: 59,135.25 kg Total Axels: 12 Total Passengers: 9 Notes: . The order of the vehicles in the vehicle list is not important. You must use arrays (and not ArrayLists) to store vehicles in the Ferry class. Vehicles are identified by their ID when searching through the list of vehicles. You may find it helpful to create a helper method in the Ferry class to return the position of a vehicle in the list. Driver program for testing: Write a driver program to test the Vehicle and Ferry classes, covering the following: . . . . Add a small number of vehicles. Try to add a vehicle that is already booked on the ferry. Try to add a vehicle that would put the ferry over its weight limit. Try to add a vehicle that would put the ferry over its passenger limit. Try to add a vehicle that would put the ferry over its axel limit. Change the number of passengers of a vehicle on the list, for cases where the new number of passengers would and would not put the ferry over its passenger limit, and for the case where the vehicle doesn't exist. Try to remove a vehicle that is on the ferry. Try to remove a vehicle that is not on the ferry. Report the remaining weight available on the ferry. Print a vehicle list. The output of your driver program should indicate the purpose of each test case and print the effects on the vehicle list and total weight, axels, and passengers after each successful operation

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

LO2 Explain the nature of the psychological contract.

Answered: 1 week ago

Question

LO1 Discuss four different views of motivation at work.

Answered: 1 week ago