Based on the below code do the following tasks: EntryScreen should be adjusted so that the when the option ‘B’ is selected from the main menu, the screen is updated to show a bus management menu. If the option to add a bus is selected, the screen should display options for the type of menu to be shown. The entry screens should allow the subclasses of class bus to be populated.
Based on the below code do the following tasks: EntryScreen should be adjusted so that the when the option ‘B’ is selected from the main menu, the screen is updated to show a bus management menu. If the option to add a bus is selected, the screen should display options for the type of menu to be shown. The entry screens should allow the subclasses of class bus to be populated.
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
Based on the below code do the following tasks:
EntryScreen
should be adjusted so that the when the option ‘B’ is selected from the main menu, the screen is
updated to show a bus management menu. If the option to add a bus is selected, the screen should
display options for the type of menu to be shown. The entry screens should allow the subclasses of
class bus to be populated. Figure 3 provides an example of the expected display. look at image uploaded
should be adjusted so that the when the option ‘B’ is selected from the main menu, the screen is
updated to show a bus management menu. If the option to add a bus is selected, the screen should
display options for the type of menu to be shown. The entry screens should allow the subclasses of
class bus to be populated. Figure 3 provides an example of the expected display. look at image uploaded
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class EntryScreen {
public EntryScreen() {}
public ArrayList<Planner> managePlanners(Scanner scan,ArrayList<Planner> plans, Ministry mny, ArrayList<Bus> buses) throws NumberFormatException
{
ReportScreen r = new ReportScreen();
char mchoice = 'c';
String menu="";
while (mchoice!='X')
{
String menuOptions = "[A]dd/Create planner\n[E]dit/Update planner\n";
menuOptions+="[L]ist/Read planner\n[D]elete planner\nE[x]it\n";
System.out.println(menuOptions);
menu = scan.next().toUpperCase();
mchoice = menu.charAt(0);
switch(mchoice)
{
case 'A':{
Planner p = createPlanner(scan, mny, buses);
if (p!=null)
plans.add(p);
break;
}
case 'L':{
Collections.sort(plans);
r.listPlanners(plans, System.out);
break;
}
case 'E':{
System.out.println("Please enter the ID of the planner to be updated:");
int pid = Integer.parseInt(scan.next());
int pdx = findPlanner(plans,pid);
if (pdx>=0)
plans.get(pdx).updateLocalData(scan);
else
System.out.println("Planner with id "+pid+ " not found.");
break;
}
case 'D':{
System.out.println("Please enter the ID of the planner to be deleted:");
int pid = Integer.parseInt(scan.next());
int pdx = findPlanner(plans,pid);
if (pdx>=0)
plans.remove(pdx);
else
System.out.println("Planner with id "+pid+ " not found.");
break;
}
}
}
return plans;
}
public Planner createPlanner( Scanner scan, Ministry mny, ArrayList<Bus> buses)
{
Planner p = null;
try
{
System.out.println("Please enter Planner Name:");
String name = scan.next();
System.out.println("Please enter Planner Budget:");
int budget = Integer.parseInt(scan.next());
p = new Planner(name, budget, mny, buses);
}
catch(NumberFormatException nfe)
{}
return p;
}
public int findPlanner(ArrayList<Planner> plans, int pid)
{
int pdx =-1;
int currdx=0;
while ((currdx<plans.size())&&(pdx==-1))
{
if (plans.get(currdx).getId()==pid)
pdx = currdx;
currdx++;
}
return pdx;
}
public int findBus(ArrayList<Bus> buses, int bid)
{
int bdx=-1;
////code needed here to find bus with id bid in arraylist of buses
return bdx;
}
}
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
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