Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By KevinWorkman
  • 1 Post By JosAH

Thread: New to java tooo...! Please HELP

  1. #1
    kevmolloy is offline Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Default New to java tooo...! Please HELP

    Hi guys,

    im new to JAVA and need to do up this problem....

    1. (a) You are developing code for a computer game called CoinSnap, which involves tossing three coins.
    Write a Java class representing a single coin, with public methods toss (randomly selects heads or tails), isHeads (returns true if the coin is heads), and toString (returns a string “Heads” or “Tails”). The class may also require one or more private member variables.
    Note: The toss method may need to use the Math.random method, which takes no parameters and returns a random double value between 0 and 1. [6]
    (b) Using the class described above, write a Java program to play CoinSnap (except for code to calculate prize money: see Part (c) below). The rules are:
    You start with €100
    Each play costs €5
    When you play, the computer tosses the three coins, displays them, and calculates your prize money, if any (this is done by calling a method to calculate the prize money: see Part (c) below)
    The prize money is added to your current amount and this is displayed
    If you run out of money, you are asked to leave and the game ends
    After each play, you are asked whether you wish to play again or finish, provided you have not run out of money
    If you decide to finish (without having run out of money), you are congratulated and the amount of money you are left with is displayed.
    The program should be carefully designed and appropriate decision structures should be selected, to avoid long-winded or repeated code. The code should be clear, neatly formatted and correctly indented. [15]
    (c) Add a method to the program to calculate prize money. This method has three parameters, each representing a coin object, and it returns the prize money calculated. The prize money is €100 if all three coins are heads, €50 if all three are tails, or €0 otherwise

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,864
    Rep Power
    8

    Default Re: New to java tooo...! Please HELP

    We aren't going to do your homework for you. Please read the link in my signature on asking smart questions, then post an SSCCE and a specific technical question, and we'll go from there.
    Kagiso likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,864
    Rep Power
    8

    Default Re: New to java tooo...! Please HELP

    I've also deleted your duplicate post. Please do not spam multiple copies of the same "question".
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,340
    Blog Entries
    7
    Rep Power
    20

    Default Re: New to java tooo...! Please HELP

    What do you want help with? All you did was dump your assignment/homework text here; we are not going to do it for you but we are willing to help if you're stuck and ask a specific question here.

    kind regards,

    Jos
    Kagiso likes this.
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

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