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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.Similar questions
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education