I SAW THAT THIS QUESTION WASN\'T COMPLETELY ANSWERED IN ALOT OF POSTS. PLEASE. I
ID: 3857117 • Letter: I
Question
I SAW THAT THIS QUESTION WASN'T COMPLETELY ANSWERED IN ALOT OF POSTS. PLEASE. I BEG.
Final Project - Memory Matching Game – Text Based Game Requirements • Create a class ‘MemoryMatchGame’, with the various variables, arrays and functions need to play the game.. Select a Theme and have 50 words associated with it. (MAX individual word length is 8 characters) Words must have a common theme - your choice Examples: Like Periodic Table Elements, or Sports teams, or Types of cars… Hint: load into a single dim array of string in class Have one Term describing category you picked. This is the FACE term… Menu User Interaction: • Level of Play – Use selects at start of game 4 x 4 grid (Easy) 6 x 6 grid (Moderate) 8 X 8 grid (Difficult) Hint: Save as a variable in the class • Speed of Play – At start of game, User selects time interval for clicked-on term-pair to display 2 seconds (Difficult) 4 seconds (Moderate) 6 seconds (Easy) Hint: Save as a variable in the class • Optional feature (have more than one theme – User would select theme) Next, Populate answer Grid with randomly selected Terms from the theme array • At start of game – program places the same face/theme term in all squares in the visible grid Answers not visible, only theme name is displayed in all squares, at start of game. • Program select # of random term from the 50 for selected theme If 4 x 4 grid, randomly pick 8 terms, place each image name twice in 2-Dim array. If 6 x 6 grid, randomly pick 18 terns, place each image name twice in 2-Dim array. If 8 x 8 grid, randomly pick 32 terms, place each image name twice in 2-Dim array. Hint: Randomly shuffle theme array and just pick the first 8, or 18 or 32 terms per game player selection Next, display the current game state on screen. Note: ‘Answer’ array is different from ‘display’ array During the course of play, the face/theme term in the display grid is replaced by a corresponding array terms, when user selects a grid square Decide on how the user select/chooses a square/cell/location that is displayed… there many different methods.. Game Play 1) User selects a FIRST square, the theme/face term in the grid square is replace with correspond stored term, from the 2-dim answer array 2) User selects a SECOND square, the term theme/face in the second grid square is replace with the corresponding stored term, from the 2-dim answer array 3) The computer compares the terms for the two selected squares. If they are the same, the terms remain on the screen and can no longer be selected. If they are different, the term remain the screen for 2, 4 or 6 seconds, depending on user selection at the beginning of the game. After that elapse time, those two grid terms are replaced with the face/theme term. ===================================== The class you write A class consists of variables/arrays and functions. All your variables/arrays and functions are to be encapsulated inside the Memory Match game class you write. The class will use 1 and 2 dimensional arrays The class will have several variables The class will have several functions – clearly named There will be NO GLOBAL VARIABLES/Arrays or functions declared above int main(). All variables and arrays and functions will be ENCAPSULATED in the class. The int main() in your code contain only two lines of code:: #include iostream; using namespace std; #include string; #include MemoryMatchGame; Int main() { MemoryMatchGame Game1; // first line - declare instance of game Game1.start(); // second line - start game } Timer (Extra credit) - Create/display a timer that keep track of the number of seconds it took to win a game. Due Saturday July 22. To receive the most credit, this project must be functional.
Explanation / Answer
package memorygame; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import java.util.Random; /** * * @author veerasam */ public class MemoryGame extends JFrame { static String files[] = {"caillou.JPG", "daddy.JPG", "mommy.JPG", "Cat.JPG", "rosy.JPG", "teddy.JPG"}; static JButton buttons[]; ImageIcon closedIcon; int numButtons; ImageIcon icons[]; Timer myTimer; int numClicks = 0; int oddClickIndex = 0; int currentIndex = 0; public MemoryGame() { // Set the title. setTitle("Memory Game"); // Specify an action for the close button. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a BorderLayout manager. setLayout(new GridLayout(2, files.length)); closedIcon = new ImageIcon("closed.JPG"); numButtons = files.length * 2; buttons = new JButton[numButtons]; icons = new ImageIcon[numButtons]; for (int i = 0, j = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.