CSC 225 Advanced Java Fall 2021 Project 3: Flash Cards · About this project For this project you will create a GUI that operates as a flash card trivia game. The data to be used for the flash cards...

I attached the instructions


CSC 225 Advanced Java Fall 2021 Project 3: Flash Cards · About this project For this project you will create a GUI that operates as a flash card trivia game. The data to be used for the flash cards (the question/answer pairs) will be stored in a txt file, written into a map, and accessed randomly. Your trivia game will keep track of the score. You may pick the topic but at least one half of the map (the key or the value or both) must be of type String. (This means mathematical trivia like multiplication facts cannot be used for this.) This will be a multi-part project that requires you to continue to explore JavaFX while also using different data structures from the Collections Framework. This project will also visit/revisit the topic of file input/output from, lowercase/uppercase String methods, and various other logic components to make a functional and interactive program for the user. Your trivia topic should allow for 15 to 20 question/answer pairs. (Enough to test but not too many.) Keep the values shorter so that the user has fewer opportunities for spelling/typing mistakes. Suggestions for topics (key → value): · States → Capitals · Periodic Table Symbol or Atomic # → Element · Words in another language → English translation · Album names → Band/Artist · Anything else that may be well suited for flash cards · Task 1: Create the HashMap I recommend referring to the structure of Lab 6 when beginning this project. Parts of it will overlap or be very similar. All components in this first task are required as outlined below. 1. Create a new JavaFX program (or recycle Lab 6). 2. Create your .txt file and fill it with your 15-20 key/value pairs and place it in your project folder. This file doesn’t have to be created/filled from within IntelliJ but it needs to reside in your project when complete. 3. Just as I did in Lab 6, set up an init() method and read in the values from your .txt file to fill a HashMap. The HashMap will be filled here but it must also be accessible in the start() method. 4. Tip: I recommend printing the contents of the HashMap back to the console from within init() just to confirm the HashMap has been filled correctly. 5. Your .txt file will not be accessed anywhere else in the program. For the rest of the program, questions/answers should be pulled from and checked using the HashMap. 6. Again, all of this is almost identical to Lab 6. · Task 2: Create the GUI Your GUI can be simplistic for this but should still be neat. You can approach the design however you wish but it must: · Display the key (question) · Eventually display the value (answer) and feedback (correct or incorrect) · Have a TextField or similar input control for the user to enter their guess · Have a way to submit the answer and see the results · Have a way to advance to the next question · Show a running total of number of questions completed and correct answers My crude example is shown but you are not obligated to set yours up this way. When my program starts, the user is shown the question (state name) (left image). After the user types in their guess and presses Check, the answer appears as well as some feedback. The stats update as well (right image). Clicking Next will advance the user to the next question. · Task 3: Functionality Listed below are key points of functionality that must be included in this project. · Key/values pairs must be pulled randomly from the hashmap. Each time I start fresh, the order should be different (in a random way). · The game needs to end after all questions have been asked. There should be no duplicates and each question should be asked. (I will provide some sample code at the end of this document that might help with this part and the random part.) · For String inputs, make sure your code can handle uppercase/lowercase deviations that the user might enter. You do not have to account for potential user misspellings. · Statistics (total questions and correct answers) should be displayed and updated after each question. · The text field must be checked to make sure it has text in it. If the user tries to click “Check” and the text field is empty, it should not check or advance. · When the user gets to the end of the game, a message of some sort should be displayed so that they know they’ve reached the end (such as “game over”) and a percentage should be displayed based on number correct. (Your score: 85%) · When the user gets to the end, there should be no other option than to just close out the window. · For an added challenge and small bonus, you can add a “start over” button that resets everything but this isn’t required. · You do not have to account for a user re-entering a second answer for the same question but you may add this feature if you’d like. (For example, if I get the answer wrong and then hit “Check”, technically I’ll be able to retype the correct answer and hit “Check” again so that I get it right. You don’t have to add functionality that checks for this. However, if you did, you might consider code that checks to see if the Check button is clicked twice in a row.) · You do not have to account for the user just clicking “Next” over and over until they get to the end. You can add functionality to prevent this behavior but it is not required. · With the exception of leaving the text field empty and/or entering answers in either uppercase or lowercase, you can generally assume that the user will operate this program as requested (for the sake of this project). · Please have no fewer than 15 key/value pairs and no more than 20. This is enough for me to grade without requiring an hour of grading per project. Code Example for Randomizing Access to a HashMap In the init() method after the HashMap (statesMap) has been created, I used the keySet() method to pull all keys (states) from the HashMap and store them in an ArrayList. This gives me access to indexing. Next, I used the shuffle() method to shuffle the Strings in the list. Later, in the start() method within my “Next” event handler, I access the ArrayList and use the contents to display the question on the screen. Since the list was shuffled at start-up, I can just go from 0 to n, with the index incrementing each time the event handler is triggered. In the “Check” event handler, I can just use the getText() method on my question label to get the state (which is the key) and then check the HashMap using that key to see if the user’s input matches the associate value with that key. · Grading As far as functionality, the following can be used as a general guide. This isn’t always exact as there are often more overlapping considerations but it should give you an idea of what you might lose if you omit any of the features. · Case accounted for in user input - 5% · Textfield checked for text and doesn’t allow empty submissions - 5% · The init() method is present and fills HashMap from txt file - 10% · Random access to HashMap with no duplicate questions/answers throughout game play- 20% · A clean ending with no further play options, an ending statement and a percentage for score - 20% · Basic functionality of flash cards - question is displayed, user input is checked, correct answer is shown, along with feedback to user, and next button that advances the user - 40%
Nov 07, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here