binibiningtinamoran

StaffWeddingEvent.java

Dec 5th, 2020 (edited)
344
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.util.ArrayList;
  3.  
  4. public class StaffWeddingEventDemo {
  5.  
  6.     // Initiate scanner
  7.     public static Scanner entry = new Scanner(System.in);
  8.     // Set number of events to be entered
  9.     public static WeddingEvent[] events = new WeddingEvent[1];
  10.  
  11.     private static ArrayList <Employee> employeeArrayList = new ArrayList <>();
  12.  
  13.     private static final int MIN_GUESTS = 5;
  14.     private static final int MAX_GUESTS = 100;
  15.  
  16.     public static void main(String[] args) {
  17.  
  18.  
  19.         // Create events
  20.         for (int i = 0; i < events.length; i++) {
  21.             System.out.print("\nEnter Details For Event " + (i + 1));
  22.  
  23.             String eventNum = askEventNum();
  24.             int numOfGuests = askNumOfGuests();
  25.             String phoneNumber = askPhoneNumber();
  26.             int appetizer = askAppetizer();
  27.             int entree1 = askEntree1();
  28.             int entree2 = askEntree2();
  29.             int dessert = askDessert();
  30.             boolean isBuffetStyle = askBuffetStyle();
  31.  
  32.             events[i] = new WeddingEvent(eventNum, numOfGuests, phoneNumber, appetizer, entree1,
  33.                     entree2, dessert, isBuffetStyle, employeeArrayList);
  34.  
  35.             buildEmployeeList(events[i]);
  36.         }
  37.  
  38.         // Display motto
  39.         displayMotto();
  40.  
  41.         // Display event details
  42.         for (WeddingEvent event : events) {
  43.             displayDetails(event);
  44.         }
  45.     }
  46.  
  47.     public static void buildEmployeeList(WeddingEvent weddingEvent) {
  48.         int totalServers;
  49.  
  50.         if (weddingEvent.isBuffetStyle) {
  51.             totalServers = 3 + (weddingEvent.getNumOfGuests() / 30);
  52.         } else {
  53.             totalServers = weddingEvent.getNumOfGuests() / 12 + 1;
  54.         }
  55.  
  56.         System.out.println("\nFor this event you need " + totalServers + " Servers on duty.");
  57.  
  58.         int totalBartenders = weddingEvent.getNumOfGuests() / 20 + 1;
  59.         System.out.println("For this event you need " + totalBartenders + " Bartenders on duty.");
  60.  
  61.         int totalNumEmployees = totalServers + 1 + totalBartenders;
  62.         int countOfServers = 0;
  63.         int countOfBartenders = 0;
  64.  
  65.         System.out.println("\nPlease enter the Servers' info...\n");
  66.  
  67.         for (int i = 0; i < totalNumEmployees; i++) {
  68.             String employeeID = askEmpID();
  69.             String firstName = askEmpFirstName();
  70.             String lastName = askEmpLastName();
  71.             double payRate = askEmpPayRate();
  72.  
  73.             if (i <= totalServers) {
  74.                 Server server = new Server(employeeID, firstName, lastName, payRate);
  75.                 System.out.println("Adding '" + server.getFirstName() + " " + server.getLastName() + "' to the list.\n");
  76.                 employeeArrayList.add(server);
  77.                 countOfServers++;
  78.                 if (countOfServers == totalServers) {
  79.                     System.out.println("All Servers have been added to the list. Time to add " +
  80.                             "Bartenders.\n");
  81.                 }
  82.             } else if (i >= totalBartenders && (i < totalNumEmployees - 1)) {
  83.                 Bartender bartender = new Bartender(employeeID, firstName, lastName, payRate);
  84.                 System.out.println("Adding '" + bartender.getFirstName() + " " + bartender.getLastName() +
  85.                         "' to the list.\n");
  86.                 employeeArrayList.add(bartender);
  87.                 countOfBartenders++;
  88.                 if (countOfBartenders == totalBartenders) {
  89.                     System.out.println("All Bartenders have been added to the list. Time to add " +
  90.                             "the Manager.\n");
  91.                 }
  92.             } else {
  93.                 Manager manager = new Manager(employeeID, firstName, lastName, payRate);
  94.                 System.out.println("Adding '" + manager.getFirstName() + " " + manager.getLastName() + "' to the list.\n");
  95.                 employeeArrayList.add(manager);
  96.             }
  97.         }
  98.     } // end buildEmployeeList()
  99.  
  100.     private static String askEmpID() {
  101.         System.out.print("Enter Employee ID # for this employee: ");
  102.         return entry.next();
  103.     }
  104.  
  105.     private static String askEmpFirstName() {
  106.         System.out.print("Enter server's first name: ");
  107.         return entry.next();
  108.     }
  109.  
  110.     public static String askEmpLastName() {
  111.         System.out.print("Enter server's last name: ");
  112.         return entry.next();
  113.     }
  114.  
  115.     public static double askEmpPayRate() {
  116.         System.out.print("Enter servers pay rate: ");
  117.         return entry.nextDouble();
  118.     }
  119.  
  120.     public static String askEventNum() {
  121.         System.out.print("\nEnter event number: ");
  122.         return entry.next();
  123.     }
  124.  
  125.     public static int askNumOfGuests() {
  126.  
  127.         System.out.print("Enter number of guests attending: ");
  128.         int numOfGuests = entry.nextInt();
  129.  
  130.         while (numOfGuests < MIN_GUESTS || numOfGuests > MAX_GUESTS) {
  131.             System.out.println("The number of guests must be between " + MIN_GUESTS + " & " + MAX_GUESTS + " guests");
  132.             System.out.print("Please enter number of guests attending: ");
  133.             numOfGuests = entry.nextInt();
  134.         }
  135.         return numOfGuests;
  136.     }
  137.  
  138.     public static String askPhoneNumber() {
  139.         System.out.print("Enter contact phone number: ");
  140.         return entry.nextLine();
  141.     }
  142.  
  143.     // Prompt user for appetizer choice
  144.     public static int askAppetizer() {
  145.         System.out.println("\nPick an Appetizer to be served: ");
  146.         for (int i = 0; i < WeddingEvent.APPETIZERS.length; i++)
  147.             System.out.println("    " + i + " " + WeddingEvent.APPETIZERS[i]);
  148.         System.out.print("Which Appetizer would you like? ");
  149.         int appetizer = entry.nextInt();
  150.  
  151.         if (appetizer < 0 || appetizer > WeddingEvent.APPETIZERS.length - 1) {
  152.             System.out.println("\nThe appetizer you selected is invalid");
  153.             System.out.println("Please select your appetizer from the list below: ");
  154.             for (int i = 0; i < WeddingEvent.APPETIZERS.length; i++)
  155.                 System.out.println(" " + i + " " + WeddingEvent.APPETIZERS[i]);
  156.             System.out.print("Which Appetizer would you like? ");
  157.             appetizer = entry.nextInt();
  158.         }
  159.         entry.nextLine();
  160.         return appetizer;
  161.     }
  162.  
  163.     // Prompt user for entree1 choice
  164.     public static int askEntree1() {
  165.         System.out.println("\nPick your first Entree to be served: ");
  166.         for (int i = 0; i < WeddingEvent.ENTREES.length; i++)
  167.             System.out.println("    " + i + " " + WeddingEvent.ENTREES[i]);
  168.         System.out.print("Which Entree would you like? ");
  169.         int entree1 = entry.nextInt();
  170.  
  171.         if (entree1 < 0 || entree1 > WeddingEvent.ENTREES.length - 1) {
  172.             System.out.println("\nThe entree you selected is invalid");
  173.             System.out.println("Please select your first entree from the list below: ");
  174.             for (int i = 0; i < WeddingEvent.ENTREES.length; i++)
  175.                 System.out.println(" " + i + " " + WeddingEvent.ENTREES[i]);
  176.             System.out.print("Which Entree would you like? ");
  177.             entree1 = entry.nextInt();
  178.         }
  179.         return entree1;
  180.     }
  181.  
  182.     // Prompt user for entree2 choice
  183.     public static int askEntree2() {
  184.         System.out.println("\nPick your second Entree to be served: ");
  185.         for (int i = 0; i < WeddingEvent.ENTREES.length; i++)
  186.             System.out.println("    " + i + " " + WeddingEvent.ENTREES[i]);
  187.         System.out.print("Which Entree would you like? ");
  188.         int entree2 = entry.nextInt();
  189.  
  190.         if (entree2 < 0 || entree2 > WeddingEvent.ENTREES.length - 1) {
  191.             System.out.println("\nThe entree you selected is invalid");
  192.             System.out.println("Please select your second entree from the list below: ");
  193.             for (int i = 0; i < WeddingEvent.ENTREES.length; i++)
  194.                 System.out.println(" " + i + " " + WeddingEvent.ENTREES[i]);
  195.             System.out.print("Which Entree would you like? ");
  196.             entree2 = entry.nextInt();
  197.         }
  198.         return entree2;
  199.     }
  200.  
  201.     // Prompt user for entree2 choice
  202.     public static int askDessert() {
  203.         System.out.println("\nPick Dessert to be served: ");
  204.         for (int i = 0; i < WeddingEvent.DESSERTS.length; ++i)
  205.             System.out.println("    " + i + " " + WeddingEvent.DESSERTS[i]);
  206.         System.out.print("Which Dessert would you like? ");
  207.         int dessert = entry.nextInt();
  208.  
  209.         if (dessert < 0 || dessert >= WeddingEvent.DESSERTS.length - 1) {
  210.             System.out.println("\nThe dessert you selected is invalid");
  211.             System.out.println("Please select your dessert from the list below: ");
  212.             for (int i = 0; i < WeddingEvent.DESSERTS.length; ++i)
  213.                 System.out.println(" " + i + " " + WeddingEvent.DESSERTS[i]);
  214.             System.out.print("Which Dessert would you like? ");
  215.             dessert = entry.nextInt();
  216.         }
  217.         entry.nextLine();
  218.         return dessert;
  219.     }
  220.  
  221.     // Prompt user for entree2 choice
  222.     public static boolean askBuffetStyle() {
  223.         System.out.print("\nWill your dinner be served buffet style? Please type TRUE or FALSE: ");
  224.         return entry.nextBoolean();
  225.     }
  226.  
  227.     // Gather details from getters for display
  228.     public static void displayDetails(WeddingEvent e) {
  229.         // Print event number
  230.         System.out.println("Event Number: " + e.getEventNum());
  231.         // Print number of guests
  232.         System.out.println("Number of Attendees: " + e.getNumOfGuests());
  233.         // Print contact number
  234.         System.out.println("Contact Number: " + e.getPhoneNumber());
  235.         // Print price per
  236.         System.out.println("Price Per Person: $" + e.getPricePerGuest());
  237.         // Print total price
  238.         System.out.println("Total Price: $" + e.getTotalPrice());
  239.         // Print type of party
  240.         System.out.println("Type Of Party: " + e.getEventTypeSelect());
  241.         // Print if large party or not
  242.         lgParty(e);
  243.         // Print dinner menu
  244.         System.out.println(e.getMenu());
  245.         System.out.println();
  246.         // Display list of employees
  247.         displayEmployees();
  248.     }
  249.  
  250.     // Gather details from getters for display
  251.     public static void displayEmployees() {
  252.         System.out.println("The staff for your party will be:\n");
  253.         for (Employee em : employeeArrayList) {
  254.             // Print emplooyee ID
  255.             System.out.println("ID: " + em.getEmployeeID());
  256.             // Print name
  257.             System.out.println("Name: " + em.getFirstName() + " " + em.getLastName());
  258.             // Print employee rate
  259.             System.out.println("Pay Rate: " + em.getPayRate());
  260.             // Print employee job title
  261.             System.out.println("Job Title: " + em.getTitle());
  262.             System.out.println();
  263.         }
  264.     }
  265.  
  266.     // Output if guest count is a large party or not
  267.     public static void lgParty(Event e) {
  268.         if (e.isLargeEvent()) {
  269.             System.out.println("Large Party: YES");
  270.         } else {
  271.             System.out.println("Large Party: NO");
  272.         }
  273.         System.out.println();
  274.     }
  275.  
  276.     // Display motto
  277.     public static void displayMotto() {
  278.         System.out.println();
  279.         System.out.println("**************************************************");
  280.         System.out.println("*                                                *");
  281.         System.out.println("*                Carly's Catering                *");
  282.         System.out.println("*  Carly's makes the food that makes it a party  *");
  283.         System.out.println("*                                                *");
  284.         System.out.println("**************************************************");
  285.         System.out.println();
  286.     }
  287. }
RAW Paste Data