Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class DayCareFacility{
- private ArrayList<Child> students;
- private ArrayList<DayCareWorker> employees;
- public static void main(String[] args) {
- var DayCare = new DayCareFacility();
- DayCare.RunDayCare();
- }
- public DayCareFacility(){
- students = new ArrayList<Child>();
- employees = new ArrayList<DayCareWorker>();
- }
- public void RunDayCare() {
- while(true) {
- printMenu();
- selectOption();
- }
- }
- public void selectOption() {
- Scanner scanLines = new Scanner(System.in);
- var userChoice = scanLines.nextInt();
- switch(userChoice){
- case 1:
- System.out.println("What is the name of the Student?");
- var stuName = scanLines.nextLine();
- System.out.println("Do you have any siblings in the program?");
- boolean sibPlan = scanLines.nextBoolean();
- System.out.println("How old is the student?");
- var stuAge = scanLines.nextInt();
- Child admittedChild = new Child(stuName, sibPlan, stuAge);
- int randomIndex = (int) (Math.random() * employees.size());
- System.out.println( "Your child will be assigned to " + employees.get( randomIndex ) + "." );
- students.add(admittedChild);
- break;
- case 2:
- System.out.println("What will be the worker's starting salary?");
- float salInput = scanLines.nextFloat();
- System.out.println("What is the worker's name?");
- var workerName = scanLines.nextLine();
- DayCareWorker newWorker = new DayCareWorker(salInput, workerName);
- employees.add(newWorker);
- case 3:
- // for
- // }
- case 4:
- DayCareWorker driller = new DayCareWorker(0, "driller");
- }
- case 5:
- System.exit(0);
- case 6:
- case 7:
- }
- }
- private void printMenu() {
- System.out.println("What operation would you like next:");
- System.out.println("(enter the operation number)");
- System.out.println("[1] Admit Child");
- System.out.println("[2] Hire Worker");
- System.out.println("[3] Students go to school");
- System.out.println("[4] Run fire drill");
- System.out.println("[5] Quit");
- System.out.println("[6] End of year");
- System.out.println("[7] Do Accounting");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement