Results 1 to 9 of 9
  1. #1
    mcutrona91 is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Bank Class for a street craps game

    Given the following information:

    The Bank class represents the Bank in a Craps game. The Bank takes the players bets. The Bank is a data class. The only information we need to manage (the field or class variable) is how much money we need to payout to the winner. If the winner bets $10, then the bank matches that for $20. The winner gets the $20.

    total payout (Double)


    Methods are needed to manage this data.

    placeBet - takes a double as an input parameter. If the input value is not negative, then the value is multiplied by 2, added to the payout value, and true is returned. otherwise, false is returned
    payout - returns the value of the payout and sets the payout to zero.
    getTotal - return the value of the payout


    So my question is, how would I go about creating this class given that information? I have already attempted it, but I feel like I am not even close to the goal I am being asked for, if the code even works. Also, the tester being used for this class is extremely focused on exact names for methods so those cannot be changed, only the body of the methods.

    Java Code:
    public class Bank
    {
        private double totalPayout;
    
        public boolean placeBet(double betAmount)
        {
            boolean positive = false;
            if (betAmount > 0)
            {
                this.totalPayout = (betAmount * 2) + getTotal();
                positive = true;
            }
            return positive;
        }
    
        public double getTotal()
        {
            return totalPayout;
        }
    
        public double payOut()
        {
            double totPayout;
            totPayout = totalPayout;
            this.totalPayout = 0;
            return totPayout;
        }
    
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Bank Class for a street craps game

    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    mcutrona91 is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Bank Class for a street craps game

    I posted that. Just needed more feedback considering I couldn't get much from that forum.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Bank Class for a street craps game

    I feel like I am not even close to the goal
    Make a list of all the features the program should have.
    Check off the ones you have finished.
    What's left?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    mcutrona91 is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Bank Class for a street craps game

    Quote Originally Posted by Norm View Post
    Make a list of all the features the program should have.
    Check off the ones you have finished.
    What's left?
    I have met all the features it requires. I explained in more detail of my issue on the post in coderanch.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Bank Class for a street craps game

    I have met all the features it requires.
    Ok, then what is your question?

    Does the code compile, execute and produce the correct result?
    Last edited by Norm; 03-02-2017 at 01:11 AM.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    mcutrona91 is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Bank Class for a street craps game

    SOLVED!. Case-sensitive issue. "payOut()" should have been "payout()"

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Bank Class for a street craps game

    SOLVED!. Case-sensitive issue. "payOut()" should have been "payout()"
    What a stupid testing system. Why didn't it tell you there was a spelling error?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Bank Class for a street craps game

    Because most of these automated testing things are very very dim.

    To be honest, if the precise naming was important then they should have provided the skeleton of the class.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Java program using Bank Class
    By haritha in forum New To Java
    Replies: 4
    Last Post: 02-02-2016, 09:52 AM
  2. setting counter in craps game....
    By meesh in forum New To Java
    Replies: 5
    Last Post: 01-22-2013, 08:14 AM
  3. Need help with my bank class
    By rpark712 in forum New To Java
    Replies: 2
    Last Post: 11-21-2011, 03:39 PM
  4. Problem with Ending Craps game
    By Ebayer in forum New To Java
    Replies: 4
    Last Post: 02-11-2011, 07:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •