Code Monkey home page Code Monkey logo

design-patterns-solutions's People

Contributors

jyoo980 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

jyoo980 huiqingru

design-patterns-solutions's Issues

AuctionHouse: solution doesn't take into account if user is highest bidder

It appears as though in the solution for AuctionHouse the user, if the user is not the highest bidder in the first round, then in subsequent rounds, the user's input is not taken into account when calculating the highest bid.

It appears that the following small change to the initiation of max in getHighestBid() would resolve this:

    private static double gethighestBid() {
        double max = auctioneer.getCurrentBid();
        for (Bidder b : bidders) {
            if (max < b.getPersonalBid()) {
                max = b.getPersonalBid();
            }
        }
        if (max == 0) {
            return auctioneer.getCurrentBid();
        } else {
            return max;
        }
    }

Here is an output from the console when running the solution for reference:

Would you like to bid again? (y/n): 
y
Enter your new bid: 200
The highest bid is currently: $200.0
Notifying bidders of the new highest bid...
Update received for: Anthony Estey, current bid is at: $200.0
Anthony Estey can't bid any higher!
Update received for: Ian Cavers, current bid is at: $200.0
Ian Cavers can't bid any higher!
Update received for: Elisa Baniassad, current bid is at: $200.0
Elisa Baniassad can't bid any higher!
Update received for: James Yoo, current bid is at: $200.0
James Yoo can't bid any higher!
Update received for: Amy Zhu, current bid is at: $200.0
Amy Zhu can't bid any higher!
Update received for: James Xiao, current bid is at: $200.0
James Xiao can't bid any higher!
The current highest bid is at: 66.0

Would you like to bid again? (y/n): 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.