FXMail2020 (Figure 1.0) is an implementation of an email client prototype that does not at this point require support for the sending or receipt of email messages. It consists of a main user interface as shown in Figure 1.0 and a dialog that displays an address book whose contents are read from a file. To be clear, you are not required to implement sending or receiving email messages. This work is primarily focussed on the creation of the user interfaces and a small amount of other work as outlined in tasks (a) to (e).
(a) Create a main user interface for the application similar to that shown in Figure 1.0. Name the main user interface class FXMail2020. The text fields and buttons at the top should be left-aligned as shown. A text area is used for the main output. The ‘Quit’ and ‘Send’ buttons should be the same size and right-aligned. A label at the bottom left is used to display status. The title bar of the application should display the application name with your own name in brackets just to the right of it.
(b) Design a simple address book dialog with a list view, ‘OK’, and ‘Cancel’ buttons. The address book dialog is invoked by clicking on a button to the right of the recipient email address text field on the main user interface (Figure 1.0).
(c) When the address book appears, a list view should be populated with names and email addresses from a file called “emails.csv”. The file should contain names and email addresses in Comma Separated Values (.csv) format. Such a file may be created in Notepad or a similar text editor. Put about four sample entries into the file, consisting of one name and email pair per line. The name should be first, followed by the email address. The two should be separated by a ‘:’ colon character.
(d) When the OK button on the address book dialog is clicked, the selected email address from the address list should be added to the recipient textbox on the main user interface (Figure 1.0). The corresponding name should not be added.
(e) Include a checkValidFormat( ) method that is called when an email address is selected. The method checks for a valid email format by simply verifying the presence of an @ symbol that is preceded by some characters (possibly including the dot) and followed by other characters. There should also be a final . (dot) that is in turn followed by some characters. If the email address format is invalid, do not add the email address and flag to the user that it is invalid.
HiLo is a card game where a card is dealt and the player has to guess whether the next card that is dealt will be higher or lower than the first card. In the application shown (Figure 1), a card is first dealt with on the left-hand side. In this case, the card is the King of Clubs. Then, a guess as to whether the next card dealt will be higher or lower is indicated, using the radio buttons in the center. On clicking the ‘Deal Second Card’ button, another card is dealt on the right-hand side. If the card dealt is in accordance with the guess of the user, then the user wins.
Five consecutive, correct guesses constitute an overall game win. A new game is begun using the menu by selecting the ‘New Game’ item. Note that for the purpose of comparing cards, only the face of the card matters. The suit, i.e, whether Hearts, Spades, Clubs, etc., is unimportant. A second card of equal face value is considered a loss for the purposes of this game.
(a) Create a project called ‘CardsHiLoGUI’. Write the JavaFX code to create a main interface for the application similar to that shown in Figure 1. Remember to create a ToggleGroup for the radio buttons and set the ToggleGroup for each button to ensure mutual exclusivity. At application startup, the card images are populated with default cards. Use comments in your code to explain your approach in relation to the GUI construction. To be clear, user interfaces must be created in code. Do not use graphical construction tools.
(b) Add a menu bar and ‘File’ menu. The ‘File’ menu should contain the items ‘New Game’, ‘Shuffle’ and ‘Exit’. Implement these menu items fully. Add a ‘Help’ menu with an ‘About’ item to show your student name and number in a dialog.
(c) Create classes for ‘Card’ and ‘DeckOfCards’ to help manage the game. The Card class should include methods such as ‘isEqual( )’, ‘isLower( )’, ‘isHigher( )’ and ‘toString( )’. DeckOfCards should include methods such as ‘dealTopCard( )’, ‘isEmpty( )’ and ‘shuffle( )’. Provide one or more constructors as appropriate for each class.
(d) Implement the dealing of each card, determination of a win/lose and user feedback in a label as shown in Figure 1. Store wins and inform the user of an overall game win on achieving 5 consecutive, correct guesses.
(e) Add a progress bar and progress indicator to indicate progress towards 5 consecutive wins leading to an overall game win. Provide appropriate feedback on achieving an overall game win. Use a stylesheet to apply an attractive look and feel to the application.