import java.util.Scanner; public class SportsBus extends Bus { private int competitorArea; private int numSecurity; private Bus bus; public SportsBus(Bus b, int competitorArea, int numSecurity) { super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry()); bus = b; this.competitorArea = competitorArea; this.numSecurity=numSecurity; } mport java.util.Scanner; public class TrainingBus extends Bus { private int teacherArea; public TrainingBus(Bus b, int teacherArea) { super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry()); this.teacherArea = teacherArea; } import java.util.Scanner; public class PartyBus extends SportsBus{ int barArea; public PartyBus(SportsBus s, int barArea) { super( s.getBus(), s.getCompetitorArea(), s.getNumSecurity()); this.barArea = barArea; } public class Bus implements Comparable { private String name; private int size; private int price; 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 price, int lev, Ministry mny) { approvedTrips=new ArrayList(); this.name = name; this.size =size; this.price = price; this.level = lev; this.id = getNextId(); this.mny = mny; tripTypes = "BASICTRANSPORT"; } public int compareTo(Bus other) { return this.getName().compareTo(other.getName()); } Task: to be completed : Complete the method loadBuses(String bfile) that reads information bus information from a file (bfile contains the filename) . Each row in the file should trigger the creation of an instance of bus or an appropriate subclass, according to the data in table 1. All buses created should be added to an arraylist. LoadBuses should return the populated arraylist. please view the images aswell thanks in advance
import java.util.Scanner; public class SportsBus extends Bus { private int competitorArea; private int numSecurity; private Bus bus; public SportsBus(Bus b, int competitorArea, int numSecurity) { super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry()); bus = b; this.competitorArea = competitorArea; this.numSecurity=numSecurity; } mport java.util.Scanner; public class TrainingBus extends Bus { private int teacherArea; public TrainingBus(Bus b, int teacherArea) { super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry()); this.teacherArea = teacherArea; } import java.util.Scanner; public class PartyBus extends SportsBus{ int barArea; public PartyBus(SportsBus s, int barArea) { super( s.getBus(), s.getCompetitorArea(), s.getNumSecurity()); this.barArea = barArea; } public class Bus implements Comparable { private String name; private int size; private int price; 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 price, int lev, Ministry mny) { approvedTrips=new ArrayList(); this.name = name; this.size =size; this.price = price; this.level = lev; this.id = getNextId(); this.mny = mny; tripTypes = "BASICTRANSPORT"; } public int compareTo(Bus other) { return this.getName().compareTo(other.getName()); } Task: to be completed : Complete the method loadBuses(String bfile) that reads information bus information from a file (bfile contains the filename) . Each row in the file should trigger the creation of an instance of bus or an appropriate subclass, according to the data in table 1. All buses created should be added to an arraylist. LoadBuses should return the populated arraylist. please view the images aswell thanks in advance
Chapter3: Data Representation
Section: Chapter Questions
Problem 3RP
Related questions
Question
import java.util.Scanner;
public class SportsBus extends Bus {
private int competitorArea;
private int numSecurity;
private Bus bus;
public SportsBus(Bus b, int competitorArea, int numSecurity)
{
super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry());
bus = b;
this.competitorArea = competitorArea;
this.numSecurity=numSecurity;
}
mport java.util.Scanner;
public class TrainingBus extends Bus {
private int teacherArea;
public TrainingBus(Bus b, int teacherArea)
{
super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry());
this.teacherArea = teacherArea;
}
import java.util.Scanner;
public class PartyBus extends SportsBus{
int barArea;
public PartyBus(SportsBus s, int barArea)
{
super( s.getBus(), s.getCompetitorArea(), s.getNumSecurity());
this.barArea = barArea;
}
public class Bus implements Comparable<Bus> {
private String name;
private int size;
private int price;
private ArrayList<Trip> 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<Trip>();
}
public Bus( String name, int size, int price, int lev, Ministry mny) {
approvedTrips=new ArrayList<Trip>();
this.name = name;
this.size =size;
this.price = price;
this.level = lev;
this.id = getNextId();
this.mny = mny;
tripTypes = "BASICTRANSPORT";
}
public int compareTo(Bus other)
{
return this.getName().compareTo(other.getName());
}
Task: to be completed : Complete the method loadBuses(String bfile) that reads information bus information from a
file (bfile contains the filename) . Each row in the file should trigger the creation of an
instance of bus or an appropriate subclass, according to the data in table 1. All buses created
should be added to an arraylist. LoadBuses should return the populated arraylist.
file (bfile contains the filename) . Each row in the file should trigger the creation of an
instance of bus or an appropriate subclass, according to the data in table 1. All buses created
should be added to an arraylist. LoadBuses should return the populated arraylist.
please view the images aswell thanks in advance
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT