Skip to content
Snippets Groups Projects
Select Git revision
  • 2fa2e2464369b7b1bf9bf1d7633a6285fe325ce1
  • 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

userTrailsTemplate.html

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Banker.java 1.57 KiB
    package com.cm6123.monopoly.game;
    
    
    /**
     * Class for the banker as seen in the pro forma, banker gives money to players.
     */
    public class Banker {
        /**
         * The initial balance of the banker.
         */
        private static final int INITIAL_BALANCE = 5000;
    
        /**
         * The current balance of the banker.
         */
        private int balance;
    
        /**
         * Adds money to the banker's balance.
         *
         * @param amount The amount of money to add.
         */
        public void addMoney(final int amount) {
            balance += amount;
        }
    
        /**
         * Constructs a new Banker instance with the initial balance.
         */
        public Banker() {
            this.balance = INITIAL_BALANCE;
        }
    
        /**
         * Pays the player and money gets subtracted from the bankers initial balance.
         *
         * @param player The player to whom the money is being paid.
         * @param amount The amount of money to pay to the player.
         */
        public void payPlayerMoney(final Player player, final int amount) {
            player.addMoney(amount);
            this.balance -= amount;
        }
    
        /**
         * Checks if a player has passed 'Home' or tile 1, this method gets called in the application class.
         *
         * @param player The player whose position is being checked.
         */
        public void checkIfPlayerPassHome(final Player player) {
            if (player.getPosition() > 1) {
                payPlayerMoney(player, 0);
            }
        }
    
        /**
         * Retrieves the current balance of the banker.
         *
         * @return The current balance of the banker.
         */
        public int getBalance() {
            return balance;
        }
    }