2/11/2024 0 Comments Simple minesweeper("Enter row and column of the cell you want to open:") Public static boolean playGame (int mines, char outputBoard) If (count=target)//if count is equal to the area, the game is over because there are no more blank spaces If(mines=1 || mines=-1)//counts bombs and used spaces Int target = mines.length*mines.length //total area of grid Private static boolean checkStatus(int mines) If(mines = 1 & i != r & j !=c)//checks around square for bombs Public static int countMines (int mines, int r, int c)įor(int j = cMin j<= cMax j++)//columns Public static void displayOutput (char output) Public static void init (int mines, char output)įor (int c = 0 c < output.length c++)įor (int c = 0 c < mines.length c++) ("Error, please try again") Ĭhoice=welcomeAndAskForSizeOfField() //a loop until correct grid size is chosen Int choice = keybd.nextInt() //input by user ("If you want to play on a 10x10 grid press 10") ("Welcome to the game of minesweeper! If you would like to play on a 5x5 grid press 5") Public static int welcomeAndAskForSizeOfField() GameOver = playGame(minesfield, outputField) Int minesfield = new int Ĭhar outputField = new char Int size = welcomeAndAskForSizeOfField() I provided sample runs to illustrate my problem. I'm fairly sure my logic is correct but I may be wrong. It compiles but when I run it, it seems to give the wrong number for the number of bombs in adjacent squares. Usually I can get everything figured out but I can't figure this out. Hello, I am a student taking APCS and I am getting very frustrated with this program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |