UML diagrams and Object Oriented programming

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

*

*/

publicclass Game

{

int usermoney;

int bet;

publicboolean playAgain()

{

}

publicint 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;

}

publicvoid Payout ()

{

int amt;

}

publicboolean 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

[2720 byte] By [Alachinea] at [2007-11-26 15:41:03]
# 1

>playAgain() : bool

>askBet() : int

>Payout(amt: void) : void

>takeBet(amt:void) : bool

These are methods of the "Game" class, and what is inside parentheses are called parameters.

"void" and "bool" are return types.

public boolean playAgain()

{

}

In this code you have specified boolean as a return type, so you need to return a value of type bool.

As for the void part, you don't need to return anything.

-

Code should look like:

public boolean playAgain()

{

return true; //Or return false

}

-

public void Payout ()

{

int amt;

}

You need to get :int amt" in the parameters, and since its voide nothing needs to be returned.

public void Payout (int amt)

{

}

Lexera at 2007-7-8 21:59:38 > top of Java-index,Java Essentials,New To Java...
# 2
thank you. Could you believe four hours of online searching couldn't return any site that could say that?
Alachinea at 2007-7-8 21:59:38 > top of Java-index,Java Essentials,New To Java...
# 3
I am glad I could help.
Lexera at 2007-7-8 21:59:38 > top of Java-index,Java Essentials,New To Java...
# 4
Hey I didn't receive my Duke reward!!?
Lexera at 2007-7-8 21:59:38 > top of Java-index,Java Essentials,New To Java...
# 5
You didn't, that's odd... Let me look into it.Message was edited by: AlachineSorry, new to the whole thing. I gave them to you.
Alachinea at 2007-7-8 21:59:38 > top of Java-index,Java Essentials,New To Java...
# 6

Not sure where your Google search took you.

This is the best book on UML ever written:

http://www.amazon.com/UML-Distilled-Standard-Modeling-Language/dp/0321193687/sr=8-1/qid=1169295653/ref=pd_bbs_sr_1/002-6711173-6699211?ie=UTF8&s=books

It's short, sweet, and to the point.

%

duffymoa at 2007-7-8 21:59:38 > top of Java-index,Java Essentials,New To Java...