File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Probably a simple answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Probably a simple answer" Watch "Probably a simple answer" New topic
Author

Probably a simple answer

Ryan Perlman
Greenhorn

Joined: Oct 31, 2001
Posts: 23
I am writing a coinToss applet. I have got the applet written except I can't figue out how to get my (tails Field) tlsField, and my (heads Field) hdsField to keep a running count as you press the toss button. They keep reseting there values back to the initial value of 1. There is a Flip Field in the code that does nothing yet because I haven't written a method to set the field to true or false yet. should I do it as a boolean or just as a string?
Here is the code


(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited November 12, 2001).]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

You need to create two variables that stores the coins count.
int headscounter = 0;
int tailscounter = 0;
These need to be initialized outside of your actionPerformed or they will reset to 0 everytime. Then, when a flip is decided, just increment one of the two variables.
headscounter++
or
tailscounter++


------------------
Happy Coding,
Gregg Bolinger


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Probably a simple answer