Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 approvedTrips; private int level; // 1,2,3 for low,medium, high repectively; private int id; private static int nextId=0; private Ministry mny; protected String tripTypes; private int getNextId(){ return nextId++; } public Bus(){ approvedTrips=new ArrayList(); } public Bus( String name, int size, int basePrice, int lev, Ministry mny) { approvedTrips=new ArrayList(); this.name = name; this.size =size; this.basePrice = basePrice; this.level = lev; this.id = getNextId(); this.mny = mny; tripTypes = "BASICTRANSPORT"; } public boolean available(Date date){ boolean retval = true; for (Trip t:approvedTrips) if (t.getDate().getDay() == date.getDay()) retval = false; return retval; } public int getBasePrice(){ return basePrice; } public int getId(){ return id; } public String getName(){ return name; } public double getSize(){ return size; } public String toString(){ return name; } public boolean isSuitable(String type){ return tripTypes.contains(type); } public int getEstimate(String type, int numPassengers, int comfortLevel){ return basePrice; } public boolean canHold(int numPassengers, int comfortLevel){ int capacity = (int)(size / mny.getSeparation(comfortLevel)); return numPassengers <=capacity; } public void promoteTrips(){ System.out.println(); System.out.println("TRIPS ON " +getName()); System.out.println("==================="); for (Trip t:approvedTrips) System.out.println(t); } public int reserve(Trip trip, Ministry mny){ int retval = -1; ApprovalRequest ar = new ApprovalRequest(trip, this); int result = mny.checkApproval(ar); if (result >=0){ int est = getEstimate(trip.getType(), trip.getNumPeople(), trip.getComfortLevel()); if (trip.getPlanner().getBudget() >= getEstimate(trip.getType(), trip.getNumPeople(), trip.getComfortLevel())){ approvedTrips.add(trip); trip.setBus(this); retval = result; } } return retval; } }

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: If the first letter of your surname is M or smaller, a PartyBus is a specialized SportBus.

calculation for PartyBus Estimated value

foodArea x superclass getEstimate(type, numPersons, level)/(3 x barArea)

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago