par Isabella Arsenault Il y a 2 années
141
Plus de détails
using this image taken from google
When each entry is added into the .txt file it would be read back into the program and turned into a doubly linked list so that the high scores can be displayed and that the program can traverse through to sort the scores highest to lowest - I think that linked lists would be the most efficient way of storing this information, especially with
Would need class for adding scores and names to a .txt file
Top 5 high scores for both games
will be able to access both of the separate game .txt files and add them to one cumulative file that has all the names and scores on them - would need to find a way to also assign a variable saying which game each high score is related to - will then go through and take the top five - back into another doubly linked list - and would have method to display the top five on another panel
would keep track of names and high scores - figure out how high scores in 2048 are calculated - in the 2048 displaying of high scores it would display all the high scores
If two player game, will have both names of player and then will add an entry for each player and the associated number of stones that ended in their zone would be treated as their high score if it was a player playing with the ai, then it would only be the player that has the score recorded when displaying - would display all the names on the file
Each of the following would have the same methods that have been discussed - the ways that they are slightly altered will be discussed under their tabs
Could maybe inherit? think about this some more would need variables - name and score would need file writer + writeFileMethod: would go through until the next pointer is null and add each line to the file at some point - possibly not in this class would then need a buffered reader to read back the file info - should probably try and keep all the file related methods in the same class would be the parent class to all the other separate game methods that would need to create the .txt file and add entries to it
For my project I want to create files with all the high scores so that all the user high scores are not lost when the user closes the window
And would need a class for the linked list operations
inherits the same but might need a different maxSize than the other two not entirely sure yet
subclass inherits same methods and variables from parent class
Subclass inherits same methods and variables from the parent class
Has variables: int maxSize, int size gameClass head, gameClass tail
Would have the following methods: void add(EntryGame newEG) void remove(String name) boolean hasNext() String toString
Would then need a node class of highscore entries
Menu Screen High Scores
2048
Mancala
node that inherits from parent class, would. need same methods - only difference would be being called in different places
Has variables: string name, int score className next, className prev
Would have the following methods: Constructor for initializing game entry that is passed in probably won't have an exception for if the user enters their info in the wrong order - instead having pop-ups that would prompt the user to enter everything in the right order but could still make an exception for in the weird case that it did happen and surround everything with a try/catch statement getters : getName, getScore, getNext, getPrev setters: setNext and setPrev toString (would pass back getName and get Score)
THIS WOULD BE THE OUTLINE OF AN ABSTRACT CLASS THAT WOULD BE THE PARENT OF ALL THE OTHER CLASSES FOR EACH GAME THAT NEEDS TO USE A HIGH SCORE each game will have a different .txt file that holds the scores, and there will be one .txt with the combined top five scores
going to be adding all the high scores to a separate .txt file where when viewing the files, the user could choose to delete a high score that is present. for deleting - ask the user if they want to delete the highest score or lowest score associated with their name - would determine which way to go through the list to find the right thing to delete
Should be keeping track of how many stones are in each slot would call on another graphics class for properly displaying the amount of stones are in each slot I would like to implement a mouse listener where if the user hovers over a slot they can see how many stones are in it
Probably going to have separate classes when implementing the ai - human turns for two player and the human part of the one player will go in one class while the ai strategy will be in a separate class - This is outlined in a class to the right
Methods for if it is 1 player Mancala and then AI would play as the other player choosing whether to make the AI just randomly choose a turn or choosing the more complex way where it would try and see if it can steal stones or if it has enough stones to get bonus turns - if I have time would be something good to consider - if not, make the ai just choose a random place to go on their own side that has stones in the slot
Methods for two player mancala needs to check when the player is choosing where is going to go and checking to make sure that the slot isn't empty and that the side that they are playing on is the side that corresponds to the right person the slots will be kept in an array of ints - the integer number representing the amount of stones that are in the slot at a time
In regards to deciding how to tell which amount of stones I need to display I'm in between two ideas currently one - use a super class of stone and have the sub classes of all the different images of the stone or create a case statement within the program
For actually creating the stones I would either paint them from scratch - take an image and edit it from online or take a picture myself of mancala stones that I have at home and get it so that there is no background behind them
Because it is possible to have so many stones in each slot I would only have animations for up to five stones in a slot then depending on the number it would display the correct number and the user could hover over to see the precise number of stones that they have
Neutral: checking if there is an option to get a bonus turn could probably check at the end if there is a way to get a bonus turn and then also perform an offensive or defensive move
Offensive: the offensive check would basically be the opposite of the defensive - the ai would check if there are any empty slots on their side and if there are in would take into account how many stones it would be stealing from it's opponent
would do the same as the defensive but could also be able to check if there are a lot of stones in the slot that the ai is assessing than it could see if it has enough stones to go around the board once and then land in the newly empty pile or another previously empty pile
Defensive: needs to check and see if the opponent has any open slots and the correct number of stones to land in the empty slot and steal the ai's stones - would take into account how many stones would be stolen
would need to loop through the array that holds the amount of stones on the opponents side, takes account of slots with 0 stones, would then have to loop through the array again - only on the opponents side and see if there are any amounts of stones on their slots that would land in the empty slot
Would be connected to the controller class - receives info from the rules/controller class about how the user is playing and would update the way that the view class is displaying its information
In the sub classes there would be a .txt file that is made for each game and the menu high scores will the top five game high scores for both available games to play in this summative
Could probably either have 3 .txt files or just have one big .txt file and then the program would need to check which game the score belonged to while it is reading through each line and adding entries to the linked list
Each subclasses of the high scores will have a read and write method for the file that contains all the high scores the file is created so that the high scores are not lost when the user quits the program
the mancala and 2048 high scores classes will display all the high scores whereas the menu high scores will only display the top five scores from both games as well as displaying which game the scores belong to
The subclasses will then read through the file and add each line (the name, score) the game variable for mancala high scores and 2048 scores would not be displayed - possibly set to null - when each entry is read in they will be added to a linked list that is sorted with the best score being at the start and the worst score being at the end
And possibly have a game entries class this class would be shared by both games
would have the following getters and setters getName getScore getNext getPrev setNext setPrev
would have a constructor
would contain variables for name, score, game, next and previous
because I am using a linked list I will create my own so I will need a doubly linked list class
have a hasnext function and then a getnumentries that could be displayed at the top/bottom of the high scores display (maybe?)
have addlast and addfirst method that would be private
Would have variables of the game entry type for the head and the tail
If i manage to add the delete button for the high scores than it would need a remove method
the linked list class would have an add method
Would probably just be using the code from the linked list assignment and change it slightly because they basically have the same purpose of the basic functions being used
Would start off with a blank .txt file for all of the high score subclasses
The parent class would have the protected variables of username. score and game
Game would be set to null for the mancala and 2048 high scores
have a getplayer and setplayer method
have pop-up messages that either disappear after a certain amount of time or have the user be able to x out of the pop-up
user chooses a slot to play that doesnt have any stones than they need to choose another slot user tries to play on the opposite players side user tries to play from one of the end zones
would take into account which slot is chosen and will add one stone to each of the next array values for the amount of stones that were in the original pile if the very last slot turns into a one - then the method for checking for stealing should occur
if last stone ends in the users end zone than they will get to play again
if last stone lands exactly on an empty slot on the users side and their opponent has stones in the opposite slot than the stones in the opponents slot gets
have some method that will be able to tell if the value of the slot from the array value is 0
The game is over is there are no more stones left on one of the sides
the player with the remaining stones on their sides gets to keep those stones
would be an array of ints, where the int value of each would represent the amount of stones that are in each slot
need some way of differentiating the end piles - maybe having them in a separate array but would still need way of adding stones to the end zones
possibly add a button that would prompt the user if pressed to ask if they want to delete an entry - this would be something to add if there is extra time
would need labels or a space on screen where the high scores are displayed
user name and amount of stones captured in end zone would be displayed
Would need buttons for navigation to menu or back to the game screen
like the mancala high scores, if time would add a delete entry button to delete a high score - based on username that the user would enter into the pop-up and then would go thru linked list of high scores until the match was found if not having a pop-up exception of username not being found come up on screen for a little bit
labels for which game the high score is related to, the user name and the actual score
Would need a button for navigation back to the menu
If I had time at the end could probably also have a pop-up appear right before the user is quitting the actual program to ask them if they are sure
Would also need popup that would appear for the user to enter their username this info would later be passed into the high scores class so that the right score is displayed with the right person
On the highest layer I will have buttons that have their visibility set to true, but they will have a transparent background and no edge it needs to be at the front so that when the user is trying to choose where to make their move then they will be able to click on the buttons instead of clicking on an image and having nothing happen
Another similar implementation of the buttons would be putting if statements for when the mouse is clicked in a certain area - in a way forming a square with x/y coords where certain intervals would correspond to a slot and the associated slot would be modified when the user's mouse is clicked in the box
For the buttons I will have a 2d array of buttons for the 12 buttons in the two rows
The end zone buttons will be in a separate 1d array
using pop-ups for the exceptions so that the console does not need to be used. either set the pop up so that the user can click to exit or so that it disappears after a certain amount of time
The end zones need buttons not so that the user would choose to move their stones if they pressed on that button, instead for the program to exception handle
One image with the stones this would be in front of the image of the game board either have a hierarchy of different stone images that would be displayed or repaint for the correct amount of stones when necessary
Would also need a label for which player's turn and a label for the winner
could also have a case statement with the different amounts of stones that should be displayed and then would just repaint accordingly
The images would all already be loading using a buffered image and then ImageIO.read(new File()) method
If using a hierarchy for the stones than there would be the abstract parent class with the main characteristics of the stone - maybe the conditions for when a different type of stone is displayed
Would have five subclasses - one for each of the different types of stones that would be displayed depending on the number of stones in each slot - see google slides for ideas of what stones will look like
I don't want to have text that is displaying the amount of stones in each slot the entire time because in a real game you wouldn't be able to count the number of stones
On the same level there would be labels next to each box that would be set to invisible and when the user would hover over each of the slots than the label would become visible and display the amount of stones that are in the slot
The labels could also probably be created in a 2d array
As the amount of stones in each slot is changed the label that displays the amount should be changed accordingly
Would need to use a mouse listener that could probably use the buttons as what the mouse listener is set to and when the mouse is hovered over the visibility will change
One image with the game board the game board would be in front of the background
At the bottom there would be three buttons on the same lvl one for resetting the game one for viewing high scores and the last would be to quit and go back to the main menu
Buttons would have action listeners for when clicked to either reset game, change to the menu panel or change to the high score panel
On the same level as this I would have a title label at the top of the panel to display which game is being played
I guess the easiest way as I am thinking about this is to have a three layers of images - one layer which will be the background and it will be at the very back of the panel
Am having a background image so I can have the panel be bigger than just the size of the board - I am ok if it is the same width as the board png but want it to be a bigger height
potentially add image or something as an icon for summative
Buttons for: going to mancala going to menu high scores - page that would hold the high scores of both games going to to play 2048 quitting the program
Clicking on these buttons would switch which panel is being displayed with the card layout
Possibly create a pop-up that when the quit button is pressed it makes sure that that was an intential choice by the user
Label for title
label for subtitle