Question
THE SPORTBUS CLASS (15 marks) The SportBus class is a specialized Bus. It stores private integer data items that represent competitorArea and spectatorArea, as well
THE SPORTBUS CLASS (15 marks) The SportBus class is a specialized Bus. It stores private integer data items that represent competitorArea and spectatorArea, as well as an ArrayList of strings, each of which represent a sport for which the bus will be configured. Methods of SportBus are as follows 1. SportBus(String name, int basePrice, int lev, Ministry mny, int competitorArea, int spectatorArea, String sportList) initialize instance -Set the size of the associated parent class is as the sum competitorArea+spectatorArea; - append ,SPORT to the protected tripTypes attribute of the superclass - split the sportList into an array, then populate the list of sports from the array (Hint. splitting a delimited string can be achieved using String.split()) 2. double getCompetitorArea() returns the area available for competitors 3. double getSpectatorArea() returns the area available for spectators 4. int getBasePrice() returns 3 * the base price of the superclass 5. int getEstimate(String type, int numPersons, int level) returns an estimated cost to run the trip. The cost is calculated as getBasePrice() * 10 * (competitorArea+spectatorArea) /competitorArea.
THE TRAININGBUS CLASS(15 marks) The TrainBus class is a specialized Bus. It stores private integer data items that represent teacherArea, studentArea and wifiRange, as well as an ArrayList of strings, each of which represent a course for which the bus will be configured. Methods of TrainingBus are as follows 1. TrainingBus (String name, int basePrice, int wifiRange, int lev, Ministry mny, int teacherArea, int studentArea, String sportList) initialize instance -Set the size of the associated parent class is as the sum teacherArea + studentArea; - append ,TRAINING to the protected tripTypes attribute of the superclass - split the sportList into an array, then populate the list of sports from the array (Hint. Splitting a delimited string can be achieved using String.split()) 2. double getTeacherArea() returns the area available for teachers 3. double getStudentArea() returns the area available for students 4. int getBasePrice() returns 2 * the base price of the superclass 5. int getEstimate(String type, int numPersons, int level) returns the 5 x teacherArea x the getEstimate method of the superclass, divided by the number of courses managed
import java.util.ArrayList;
public class Bus { private String name; private int size; private int basePrice; private ArrayList
The int planTrip(int numPassengers, String tripType, Date date, int comfortLevel) method of Planner plans an trip of a given type with the specified number of passengers on the specified date. Steps include: a. Determine the set of buses that the promoter can afford b. Find the lowest cost Bus from the set of affordable buses that i. can hold the number of passengers and ii. is available c. If there is at least one Bus that meets the requirements i. Create an instance of a Trip ii. Call the reserve method of the Bus and capture the return value in an integer iii. If the return value is greater than or equal to 0, 1. Call the setBus method of the trip to the selected bus 2. Pay for the selected bus 3. Return the return value as the result of planTrip d. If plans for the trip did not work out, return -1
add the int planTrip to the following code
import java.util.ArrayList;
public class Planner { private String name; private double budget; private Ministry mny; private Bus[] buses; private ArrayList
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started