Assign2/src/ebook/controller/EbookingEventNotDefineException.java Assign2/src/ebook/controller/EbookingEventNotDefineException.java package ebook.controller;...

The questions are in the files


Assign2/src/ebook/controller/EbookingEventNotDefineException.java Assign2/src/ebook/controller/EbookingEventNotDefineException.java package ebook.controller; public class EbookingEventNotDefineException extends Exception {     /**      *       */     private static final long serialVersionUID = 1L;          public EbookingEventNotDefineException(String event) {         super(event);     } } Assign2/src/ebook/controller/IEbookingReaction.java Assign2/src/ebook/controller/IEbookingReaction.java package ebook.controller; /**  * The implementation of this interface provides the reactions for Ebooking system.   *   * @author ssome  *  */ public interface IEbookingReaction {     void lookupReservation();     void displayFlight();     void errorMessage();     void askForReservationNumber();     void askForBaggages();     void displayReservationDetails();     void displayNewFlightInfo();     void askCustomerWishToChange();     void printBoardingPass();     void ejectBoardingPass();     void askForNumberOfPieces();     void printBaggageSlips();     void ejectBaggageSlips();     void displayProceedsToAgentMessage();     void stopAlarm();     void startAlarm(); } Assign2/src/ebook/controller/EbookingControl.java Assign2/src/ebook/controller/EbookingControl.java package ebook.controller; public class EbookingControl {     enum Status {IDLE, LOOKINGUPRESERVATION, DISPLAYINGFLIGHT, WAITFORRESPONSE,          WAITFORBAGGAGENUMBERS,WAITFORDOCUMENTSWITHRAWAL, SOUNDINGALARM}          private Status current;     private IEbookingReaction reactions;          public EbookingControl(IEbookingReaction react) {         setReactions(react);         // set initial state         setCurrent(Status.IDLE);      }          public Status getCurrent() {         return current;     }     public void setCurrent(Status current) {         this.current = current;     }          public IEbookingReaction getReactions() {         return reactions;     }     public void setReactions(IEbookingReaction reactions) {         this.reactions = reactions;     }          public void reservationNumber() throws EbookingEventNotDefineException {         if (current == Status.IDLE) {             reactions.lookupReservation();             setCurrent(Status.LOOKINGUPRESERVATION);         } else {             throw new EbookingEventNotDefineException("reservationNumber");         }     }          public void found() throws EbookingEventNotDefineException {         if (current == Status.LOOKINGUPRESERVATION) {             reactions.displayFlight();             setCurrent(Status.DISPLAYINGFLIGHT);         } else {             throw new EbookingEventNotDefineException("found");         }     }          public void notFound() throws EbookingEventNotDefineException {         if (current == Status.LOOKINGUPRESERVATION) {             reactions.errorMessage();             reactions.askForReservationNumber();             setCurrent(Status.IDLE);         } else {             throw new EbookingEventNotDefineException("notFound");         }     }          public void confirm() throws EbookingEventNotDefineException {         if (current == Status.DISPLAYINGFLIGHT) {             reactions.askForBaggages();             setCurrent(Status.WAITFORRESPONSE);         } else {             throw new EbookingEventNotDefineException("confirm");         }     }          public void change() throws EbookingEventNotDefineException {         if (current == Status.DISPLAYINGFLIGHT) {             reactions.displayReservationDetails();             reactions.askCustomerWishToChange();         } else {             throw new EbookingEventNotDefineException("change");         }     }          public void cancel() throws EbookingEventNotDefineException {         if (current == Status.DISPLAYINGFLIGHT ||                  current == Status.WAITFORBAGGAGENUMBERS ||                 current == Status.WAITFORDOCUMENTSWITHRAWAL ||                 current == Status.WAITFORRESPONSE ) {             reactions.askForReservationNumber();             setCurrent(Status.IDLE);         } else {             throw new EbookingEventNotDefineException("cancel");         }     }          public void no() throws EbookingEventNotDefineException {         if (current == Status.WAITFORRESPONSE) {             reactions.printBoardingPass();             reactions.ejectBoardingPass();             setCurrent(Status.WAITFORDOCUMENTSWITHRAWAL);         } else {             throw new EbookingEventNotDefineException("no");         }     }          public void yes() throws EbookingEventNotDefineException {         if (current == Status.WAITFORRESPONSE) {             reactions.askForNumberOfPieces();             setCurrent(Status.WAITFORBAGGAGENUMBERS);         } else {             throw new EbookingEventNotDefineException("yes");         }     }          public void numberOfPieces() throws EbookingEventNotDefineException {         if (current == Status.WAITFORBAGGAGENUMBERS) {             reactions.printBoardingPass();             reactions.ejectBoardingPass();             reactions.printBaggageSlips();             reactions.ejectBaggageSlips();             reactions.displayProceedsToAgentMessage();             setCurrent(Status.WAITFORDOCUMENTSWITHRAWAL);         } else {             throw new EbookingEventNotDefineException("numberOfPieces");         }     }          public void withdrawDocuments() throws EbookingEventNotDefineException {         if (current == Status.WAITFORDOCUMENTSWITHRAWAL) {             reactions.askForReservationNumber();             setCurrent(Status.IDLE);         } else if (current == Status.SOUNDINGALARM) {             reactions.stopAlarm();             reactions.askForReservationNumber();             setCurrent(Status.IDLE);         } else {             throw new EbookingEventNotDefineException("withdrawDocuments");         }     }          public void timeout() throws EbookingEventNotDefineException {         if (current == Status.WAITFORDOCUMENTSWITHRAWAL) {             reactions.startAlarm();             setCurrent(Status.SOUNDINGALARM);         } else {             throw new EbookingEventNotDefineException("timeout");         }     } } Assign2/src/ebook/simulator/BasicReactions.java Assign2/src/ebook/simulator/BasicReactions.java package ebook.simulator; import ebook.controller.IEbookingReaction; public class BasicReactions implements IEbookingReaction {     @Override     public void lookupReservation() {         System.out.println("lookupReservation");     }     @Override     public void displayFlight() {         System.out.println("displayFlight");     }     @Override     public void errorMessage() {         System.out.println("errorMessage");     }     @Override     public void askForReservationNumber() {         System.out.println("askForReservationNumber");     }     @Override     public void askForBaggages() {         System.out.println("askForBaggages");     }     @Override     public void displayReservationDetails() {         System.out.println("displayReservationDetails");     }     @Override     public void displayNewFlightInfo() {         System.out.println("displayNewFlightInfo");     }     @Override     public void askCustomerWishToChange() {         System.out.println("askCustomerWishToChange");     }     @Override     public void printBoardingPass() {         System.out.println("printBoardingPass");     }     @Override     public void ejectBoardingPass() {         System.out.println("ejectBoardingPass");     }     @Override     public void askForNumberOfPieces() {         System.out.println("askForNumberOfPieces");     }     @Override     public void printBaggageSlips() {         System.out.println("printBaggageSlips");     }     @Override     public void ejectBaggageSlips() {         System.out.println("ejectBaggageSlips");     }     @Override     public void displayProceedsToAgentMessage() {         System.out.println("displayProceedsToAgentMessage");     }     @Override     public void stopAlarm() {         System.out.println("stopAlarm");     }     @Override     public void startAlarm() {         System.out.println("startAlarm");     } } Assign2/src/ebook/simulator/Simulator.java Assign2/src/ebook/simulator/Simulator.java package ebook.simulator; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ebook.controller.EbookingControl; import ebook.controller.EbookingEventNotDefineException; public class Simulator {          public static void main(String[] args) {         // create controller         EbookingControl controller = new EbookingControl(new BasicReactions());         // get event and process         BufferedReader keyboard = new BufferedReader( new InputStreamReader(System.in));         while (true) {             System.out.print("Next Event: ");             try {                 String input = keyboard.readLine();                 if (input.equals("reservation number")) {                     controller.reservationNumber();                 } else if (input.equals("found")) {                     controller.found();                 } else if (input.equals("not found")) {                     controller.notFound();                 } else if (input.equals("CHANGE")) {                     controller.change();                 } else if (input.equals("CONFIRM")) {                     controller.confirm();                 } else if (input.equals("NO")) {                     controller.no();                 } else if (input.equals("YES")) {                     controller.yes();                 } else if (input.equals("number of pieces")) {                     controller.numberOfPieces();                 } else if (input.equals("withdraw documents")) {                     controller.withdrawDocuments();                 } else if (input.equals("TIMEOUT")) {                     controller.timeout();                 } else if (input.equals("cancel")) {                     controller.cancel();                 } else {                     System.out.println("Not a supported event, try again");                 }             } catch (IOException e) {                 e.printStackTrace();             } catch (EbookingEventNotDefineException e) {                 e.printStackTrace();             }         }      } }
Jul 04, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here