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. This should be done for Bus, TrainingBus, SportsBus, PartyBus 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"; } import 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 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; } 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; } Here is how it's done for the bus class case 4: //regular bus { Bus b = new Bus(nextLine[0], Integer.parseInt(nextLine[1]),Integer.parseInt(nextLine[2]),Integer.parseInt(nextLine[3]), mny); blist.add(b); break; } make sure the index are right for the arrays and take into consideration the constructors and what type each is for the different bus classes look at image uploaded please
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. This should be done for Bus, TrainingBus, SportsBus, PartyBus 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"; } import 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 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; } 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; } Here is how it's done for the bus class case 4: //regular bus { Bus b = new Bus(nextLine[0], Integer.parseInt(nextLine[1]),Integer.parseInt(nextLine[2]),Integer.parseInt(nextLine[3]), mny); blist.add(b); break; } make sure the index are right for the arrays and take into consideration the constructors and what type each is for the different bus classes look at image uploaded please
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter6: Creating, Sorting, And Querying A Table
Section: Chapter Questions
Problem 3AYK
Related questions
Question
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. This should be done for Bus, TrainingBus, SportsBus, PartyBus
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";
}
import 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 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;
}
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;
}
Here is how it's done for the bus class
case 4: //regular bus
{
Bus b = new Bus(nextLine[0], Integer.parseInt(nextLine[1]),Integer.parseInt(nextLine[2]),Integer.parseInt(nextLine[3]), mny);
blist.add(b);
break;
}
make sure the index are right for the arrays and take into consideration the constructors and what type each is for the different bus classes look at image uploaded please
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 3 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
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning