• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Probably a simple answer  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!