
That method plays the entire game, it doesn't just start it. Also, it's swarming with nested conditionals and loops. When creating the board, determine how many squares must be marked in order to win when putMarker() puts a marker (inside the containsKey conditional), increment a markers counter when markers = markersRequired then the board is won. Why is there a won() and checkWin() method? And if won() is really, really needed, why doesn't checkWin() call it?ĮvalBoard() shouldn't be necessary. It looks like a bug to me (if BOARD_DIM is 5, then this is executed on the 12th event. This block deserves a comment, or better, to be moved to a self-documenting method. Putting Random rand = new Random() inside the loop is wasteful of resources, and will occasionally cause nextInt() to return the same value on consecutive occasions due to reseting the random number generator, rather than getting the next number from the same generator. * Chooses events and adds them to the board. If you are going to add per-method comments, might as well teach yourself javadoc while you're at it: /** Prefer public or private, as appropriate.ĭelegate from one constructor to another, where you can. Private String board = new String, etc.ĭon't use default scoping unless you really mean to. Initialize variables inline where you can, to reduce boilerplate: ("Player %d wins!\n\n",boards.getPlayer())

Private final int DEFAULT_PLAYER_COUNT = 2 įor(int i = 1 i events = (ArrayList) eventList.clone() īingoBoard board = new BingoBoard(events,i) Chooses events and adds them to the board.

Public void updateEvents(ArrayList eventList)
#Bluej source code for poker game free
Private final String FREE = "FREE SPACE" īoard = new String īingoBoard(ArrayList eventList, int numb) Private final int MAX_SIZE = BOARD_DIM * BOARD_DIM Is there anything that I should do differently or improve on? Besides the oop principals, I tried to make the code very readable and reusable in case there was ever a 7x7 or a 3x3 version of bingo, and I also tried to eliminate magic numbers. I feel like I have accomplished this, but I would like to learn as much as possible from this exercise.

I've recently wrote a simple bingo game in Java to refresh myself in oop principals I have not touched in quite a while.
