Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: keeping a tally

  1. #1
    Junior Member Neo's Avatar
    Join Date
    Feb 2011
    Location
    Ohio
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default keeping a tally

    what is the code needed to keep a running tally on a game? i have created a random letter generator and i have coded it so that the user gets 4 attempts to guess the letter. i have all that coded in and working great. i have created a loop allowing the game to run as many times as the user says it's ok to run. i can't figure the coding out to tally the wins/loses.
    Last edited by Neo; February 2nd, 2011 at 02:28 PM.


  2. #2
    Member vanDarg's Avatar
    Join Date
    Jan 2011
    Location
    Chicago
    Posts
    65
    My Mood
    Mellow
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: keeping a tally

    Outside of your loop, create a variable for wins and one for losses. Within the loop, after an event happens which would tally a win or loss, just add one to the variable.

    int wins = 0;
    int losses = 0;
     
    //within loop:
     
    wins = wins + 1;
      //or
    losses = losses +1;

    If you posted your code, it may be a little easier to help.

  3. #3
    Junior Member Neo's Avatar
    Join Date
    Feb 2011
    Location
    Ohio
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: keeping a tally

    ok this is a dumb thread. sorry i figured it out and i feel stupid for posting here too quick.

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: keeping a tally

    Don't worry about it Neo. Everyone has to start somewhere!

    Let us know if you still need help with this.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Keeping Variable Values
    By The_Mexican in forum Java Theory & Questions
    Replies: 6
    Last Post: November 27th, 2010, 03:02 PM
  2. Keeping objects in webservice
    By ashleypursglove in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 16th, 2010, 11:02 AM
  3. keeping an drawing centered in Graphics
    By dvsumosize in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 27th, 2010, 10:26 PM