Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you do this in Java please THANKS IN ADVANCE The Ministry of Transport of the hypothetical island of Jamrock is convinced that a managed,

can you do this in Java please THANKS IN ADVANCE

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

The Ministry of Transport of the hypothetical island of Jamrock is convinced that a managed, ondemand bus service is essential to for the country to function, given the heavy reliance of it's citizens on unreliable "robots", which transport persons without authorization. Ministry protocols have therefore been established that regulate operation of the on-demand service. The current protocols that require your attention as a programmer, involve the implementation of a ApprovalRequest process for various types of Buses. Use of the process requires that a Planner who intend to organize Trips identify an appropriate Bus and then instruct the Bus crew to submit a request to the Ministry of Transport for approval. If the approval is successful, the Planner pays the Bus for the running the Trip. Your immediate task is to implement the detailed design for classes Date, SportBus, TrainingBus and PartyBus, then complete some logic inside Planner. SUBMISSION INSTRUCTIONS Your submission will be made on OurVLE, . All files in your submission will be placed in a directory of the name .Project1 and then the directory will be zipped. The zip file will be submitted. As an example, if your ID number is 620011011, the zip file should be named 620011011.Project1.zip PART A. Business Rules The main entities driving the process are instances of Ministry, Bus, and Planner. A Planner plans a Trip, then assesses Buses for suitability, availability, and affordability. A request to assign the Trip to lowest cost suitable Bus is then submitted to the Ministry, and is approved if the daily maximum number of travellers would not be exceeded(for the comfort level). If the Ministry approves the request, an approval Id is returned to the Planner, otherwise the value 1 is returned, and a message printed. The process uses a simple implementation of a Date. PART B. Starting code Code the following classes have been provided: Bus, Ministry, ApprovalRequest, Trip, Planner, and Date. Some methods are not fully implemented. Incomplete methods are described in section C. Methods available are described below THE BUS CLASS The public methods required of the Bus class involve 1. Bus 0 - A default constructor 2. Bus( String name, double size, double basePrice, int lev) - Initializes instance. 3. boolean available(Date date)- Returns whether the Bus is available on a specified date. A bus can run one trip per day in this model. Availability is determined by looking through the list of approved trips to see if the date on any trip matches the date in the argument. 4. int getId 0 - Returns the id of the bus 5. String getName0 - Returns the name of the bus 6. double getSized - Returns the size of the bus 7. boolean isSuitable(String type) - Returns true if the bus is suitable for a trip type. 8. String toString0 - Return the name of the bus. 9. int getEstimate(String type, int numPersons, int level) - Returns the base price. 10. boolean canHold(int numPassengers, int comfortLevel)- Returns true if the bus can hold the specified number of passengers at the desired comfort level. 11. void promoteTrips 0 - Prints a header for the Bus followed by the toString method of each approved Trips for the Bus 12. int reserve ( Trip trip,double availBal, Ministry mny) - attempts to reserve a trip with the Ministry. If the reservation is successful, a positive approval ID , obtained from the Ministry is returned. If not the method returns 1. THE MINISTRY CLASS A Ministry exposes one public method, namely checkApproval0, which has the following behaviour: int checkApproval(ApprovalRequest ar) assesses an approval request to see if an trip should be run based on prevailing rules, and returns the id of the approval request if it is determined that the trip should be run. If the trip should not be run the method returns 1. The method determines the maximum number of travelers for the day based on the comfort level and returns a positive integer if the trip would not result in the maximum being exceeded. Otherwise the method returns 1. THE APPROVALREQUEST CLASS The ApprovalRequest class exposes the following public methods: 1. ApprovalRequest(Trip trip, Bus bus) - instantiates an approval request, and assigns a reference to an Trip and a Bus. It then assigns a unique consecutively increasing id. The first id has value 0 . 2. int getId 0 - returns the id of the ApprovalRequest 3. Trip getTrip0 - returns the Trip associated with the ApprovalRequest 4. Bus getBus 0 - returns the Bus associated with the ApprovalRequest THE TRIP CLASS The Trip class manages trip information Public methods available include 1. Trip(String name, String type, int numPeople, Date date )- Initializes a local instance of a trip by storing submitted data 2. String getName0 - returns the name 3. String getType 0 - returns the associated type of trip 4. int getNumPeople0 - returns the number of people who are expected on the trip 5. Date getDate0 - returns the date of the trip 6. Bus getBus0 - returns the bus to be used for the trip -returns null of no bus is assigned. 7. void setBus(Bus b) - sets the bus associated with the trip to b 8. String toString 0 - returns a string of the format "Date:"+this.getDate0+";Name:"+this.getName(0+";Type:"+this.getType(0+";Bus:"+this.getBus(++":n umPeople:"+this.getNumPeople(0; THE PLANNER CLASS The Planner class represents an trip organizer who comes up with a trip idea and initiates the process of getting it approved. Public methods include 1. Planner (String name, double budget, Ministry mny, Bus[] buses) - Initializes an instance of a promoter, by setting a name and a budget. An association to the ministry as well as set of buses is also established. 2. double getBudget [ - returns the budget associated with the planner 3. String getName 0 - returns the name associated with the planner 4. void payFor(Bus bus, Trip trip , int numPassengers, int comfortLevel) - Pays for the bus and reduces the budget by the cost 5. int planTrip(minBus, tripType, numPassengers, comfortLevel) METHOD INCOMPLETE. CODE TO BE WRITTEN DESCRIBED IN SECTION C. THE DATE CLASS Most code for the date class is to be implemented as described in section C. THE DRIVER CLASS (Code provided) The Driver class contains a main method that can be used to test the classes described above. The version provided instantiates a set of Planners, an instance of Ministry, and a set of Buses. It then allows planners to plan trips of various types and sizes over a period of five days.txt PART C. Code you are required to write You are required to write code to complete the classes Date and Planner. You will also implement the classes SportBus, TrainingBus, and PartyBus. Do not change the given starting code for other given classes. Otherwise you are free to select the implementation strategies that meet the requirements. THE DATE CLASS(5 marks) The Date class, used to represent a date in the system, exposes the following public methods 1. Date(int day) - instantiates a Date object, by setting it's internal value to day 2. void setDay(int day) set's the internal value to day 3. int getDay 0 - returns the internal value 4. Date next(int day) - returns a date corresponding to argument incremented by 1 5. String toString0 - returns a string representation of the internal value (Hint if you haven't picked it up yet - it's ok to use a simple integer to represent the internal valueat least for this implementation) 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 " S 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(O) 2. double getCompetitorArea 0 - returns the area available for competitors 3. double getSpectatorArea O - returns the area available for spectators 4. int getBasePrice 0 - 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 010 (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(O) 2. double getTeacherArea 0 - returns the area available for teachers 3. double getStudentArea0 - returns the area available for students 4. int getBasePrice 0 - returns 2 * the base price of the superclass 5. int getEstimate(String type, int numPersons, int level) - returns the 5 teacherArea x the getEstimate method of the superclass, divided by the number of courses managed. THE PARTYBUS CLASS(40 marks) Some persons were concerned over whether a ministry should be getting involved with an activity that could be considered non-productive. To appease detractors, the ministry came up with a solution that every party should have a purpose. The effect on your implementation is that your PartyBus will be EITHER a specialized SportBus or a specialized TrainingBus. Note also that the Ministry of Transport wants to evaluate multiple potential solutions, so has prescribed that the pool of programmers (which include you), submit a solution that meets the following criteria: 1. If the first letter of your surname is M or smaller, a PartyBus is a specialized SportBus. 2. If the first letter of your surname is N or larger, a PartyBus is based on a TrainingBus. Please be very careful to submit an appropriate solution. Failure to do so will produce an automatic zero for this section. The PartyBus has attributes that represent a barArea, a foodArea and a securityCrew. It' s constructor initializes the instance, and appends ", PARTY" the protected tripTypes attribute. The PartyBus ererleads-overrides the getEstimate method. Again, the ministry seeks to assess various models. Your calculation for the getEstimate method will be determined by the last digit of your UWI student ID number. Please note the calculations in the table below and implement the appropriate one for your solution. Please be very careful to submit an appropriate solution. Failure to do so will produce an automatic zero for this section. COMPLETING THE PLANNER CLASS(25 marks) 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

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_2

Step: 3

blur-text-image_3

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

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions

Question

When is it appropriate to use a root cause analysis

Answered: 1 week ago