Skip to content
Snippets Groups Projects
Select Git revision
  • 739f4c54ddbef6330016c38bff9416dad8303a63
  • main default protected
  • Gabes-testing-branch
  • 81-as-a-child-i-want-a-very-flashy-and-modern-looking-webpage-that-will-draw-me-in-and-keep-me
  • locationApporvalFormValidationUpdate
  • 74-as-a-user-i-want-to-see-a-page-of-local-authorities-so-that-i-can-easily-source-contact-details
  • businesses
  • 77-as-a-user-i-want-to-be-able-to-use-the-application-on-any-device-e-g-iphone-ipad-laptop
  • 69-as-a-user-i-would-like-a-town-specific-page-which-shows-all-trails-for-that-town-so-that-i-can
  • 80-as-a-convenience-enthusiast-i-want-a-drop-down-menu-to-be-able-to-quickly-scan-qr-codes-i-find
  • 82-as-a-site-admininstrator-i-want-to-be-able-to-review-submited-trail-checkpoints-by-bussiness
  • 68-as-a-user-i-would-like-to-see-a-map-containing-all-landmarks-for-a-trail-and-a-suggested-path
  • 70-as-a-repeat-trail-visitor-i-want-to-be-able-to-create-an-account-so-i-can-save-and-review-my
  • towns
  • DTFrontEnd
  • 52-as-a-user-i-would-like-to-see-a-map-of-the-landmarks-so-that-i-can-figure-out-where-to-go
  • 73-as-a-qr-scanning-connoisseur-i-want-to-unlock-stickers-after-scanning-a-qr-code-to-feel-a-sense
  • QRCodes
  • consumers
  • foreignkeys
  • cleanup
21 results

userProfile2.css

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    GameEndings.java 1.59 KiB
    package com.cm6123.monopoly.game;
    
    
    import java.util.ArrayList;
    
    /**
     * Class for GameEndings if round max reach and declare winner.
     */
    public final class GameEndings {
    
        private GameEndings() {}
    
            /**
             * Checks if the round inputed by the user has reached the number of rounds.
             *
             * @param round The current round number, rounds start at 1.
             * @param numberOfRounds The number of rounds the user wants.
             * @return true if the round has reached or exceeded the maximum number of rounds, false otherwise.
             */
            public static boolean checkRoundsReached (final int round, final int numberOfRounds){
                if (round >= numberOfRounds) {
                    System.out.println("Game over! Max rounds reached");
                    return true;
                }
                return false;
            }
    
            /**
             * Determines the winner by checking which player has the most money.
             * Prints out the winner's name and money amount.
             *
             * @param players The list of players in the game.
             */
            public static void determineWinner (final ArrayList<Player> players){
                Player winner = null;
                int maxMoney = 0;
    
                for (Player player : players) {
                    if (player.getMoney() > maxMoney) {
                        maxMoney = player.getMoney();
                        winner = player;
                    }
                }
                if (winner != null) {
                    System.out.println("The winner is... " + winner.getName() + " with £" + winner.getMoney() + "!!!!");
                }
            }
        }