Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UML diagrams and Object Oriented programming

807599Jan 20 2007 — edited Jan 20 2007
In a project for CSC120 at school we have to program a casino using java. We were given a UML diagram of how the professor wants it set up, and I am having some difficulty understanding exactly what some of this means, code wise.

Part of the UML diagram:

______________
Game
_____________
userMoney: int
bet: int
_____________
playAgain() : bool
askBet() : int
Payout(amt: void) : void
takeBet(amt:void) : bool


I understand the first two blocks, but the last one confuses me. I get that these are the different functions the class will use, but what does the text inside the parentheses mean, and the text after the colon? And what would this look like in code? If someone could post a link to an example program it would greatly help, or just post a simple example here.

Here is what I have so far in the class file:
/*
 * ASCIIcasino.java
 * Version 1.0
 * Alachine
 * Last Modified: 01/19/2006
 *
 */


public class Game 
{
	
	int usermoney;
	int bet;
	
    public boolean playAgain() 
    {
    	
    }
    
    public int askBet ()
    {
    	
    	do 
		{
			System.out.println("How much do you wish to bet?");
			scannergameinput = new Scanner(System.in);
		}
		
		while(!scannergameinput.hasNextInt());
		bet = scannergameinput.nextInt();
		
		System.out.print("Your bet: ");
    	return bet;
    }
    
    public void Payout ()
    {
    	int amt;
    	
    	
    }
    
    public boolean takeBet ()
    {
    	int amt;
    	
    }
    
}
Am I doing this correctly so far, or what am I not getting? Thank you for your time.

Edited to update code.

Message was edited by:
Alachine
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2007
Added on Jan 20 2007
6 comments
401 views