aCiotola / ReservationSys

Software Dev 3 - Assignment
0 stars 0 forks source link

Part 2 – Simple Text User Interface (TUI) application #23

Open aCiotola opened 7 years ago

aCiotola commented 7 years ago

We will now code a basic menu driven TUI application that will allow a user to connect and interact with the hotel database. This application will provide commands that reflect some of the DawsonHotel system. Refer to the given sample output run to see which commands must be implemented (page 4).

The additional text user interface types required:

  1. The groupX.hotel.ui.TextView class: This class is your responsibility • It must implement Observer. • The constructor gets a handle to an Observable model and adds itself to the model’s observer list • The update method public void update(Observable o, Object arg) must look at the type of the Object arg, and based on the type, display the appropriate information. Use private methods for each of the different displays. Note that when you are checking if the type of a generic type, you will need to use the wildcard syntax (i.e., if (arg instanceof Optional<?>), and you will get an unchecked warning when you cast e.g., (Optional) arg) • Notice that the view to display a Customer will be the same, even though two different actions can cause it (i.e., a Customer is displayed both when you register and when you update credit card information)

  2. The groupX.hotel.ui.TextController class (partial code provided in S:\CompSci\317\ReservationSys\code). Please review the provided code so that you understand it, and the additions that you must make (TODO). You will notice that some helper methods have been provided, you can use them or code your own. Notice that: • it has the following private member: private HotelManager model;

• The Command enum is used to determine the user’s request: private enum Command { CUSTOMER_INFO, REGISTER_CUSTOMER, CREATE_RESERVATION, RESERVATION_INFO, CHANGE_CREDITCARD, STOP }

• it has the following constructor which sets the private variable:

public TextController(HotelManager model)

• Notice that the controller will interact with a HotelManager -> this is the Model interface (Hotel implements HotelManager), but it is not Observable. Since the Controller is not observing the model, we can program to the interface. • The method public void run() which is the main loop of the application. This method will:

• when the user chooses Stop, the hotel is closed, and all changes are persisted.

  1. The groupX.hotel.ui.TextApp class is provided in S:\CompSci\317\ReservationSys\code. It instantiates the required objects and invokes the controller’s run method.

Execute the application to ensure that it functions as expected. Refer to the given sample output run (page 4).