aspose file tools*
The moose likes Beginning Java and the fly likes What's the problem here? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What Watch "What New topic
Author

What's the problem here?

Jesse Crockett
Ranch Hand

Joined: Feb 03, 2005
Posts: 129
This program should take input as follows:

enter number of players,i.e. "2"

enter number of games, i.e. "1"

game 1, player number: "1"
hits: 1
walks: 2
outs: 3

game 1, player number: "2"
hits: 3
walks: 2
outs: 1

game 1, player number: [enter "-1" when all players are accounted for]

2 3 2 1
2 3 2 1

the output should be:

1 1 2 3
2 3 2 1

What is wrong with the the program?



marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

  • If it doesn't compile, then what are the errors?
  • If it generates runtime errors, then what are these errors?
  • If it compiles and runs, but gives unexpected output, then what is the output?

  • [ April 22, 2006: Message edited by: marc weber ]

    "We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
    sscce.org
    Jesse Crockett
    Ranch Hand

    Joined: Feb 03, 2005
    Posts: 129
    Pardon, but all three of those bullet points are accounted for.
    If there were compilation or runtime errors, I would have noted them.
    Surely you won't miss the given output...
    [ April 22, 2006: Message edited by: Jesse Crockett ]
    Michael Dunn
    Ranch Hand

    Joined: Jun 09, 2003
    Posts: 4632
    > Surely you won't miss the given output...

    Surely you don't expect everyone to have your Player class so we can
    run the program and observe the given output
    Jesse Crockett
    Ranch Hand

    Joined: Feb 03, 2005
    Posts: 129
    You mean the Player class in my post?

    How does either response make sense?
    Keith Lynn
    Ranch Hand

    Joined: Feb 07, 2005
    Posts: 2367
    I believe the problem you're experiencing is because the variables inside the Player class are static. This means that no matter how many instances of Player you create, there will only be one copy of those variables.
    Jesse Crockett
    Ranch Hand

    Joined: Feb 03, 2005
    Posts: 129
    Thanks, that solves it.
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Jesse Crockett:
    ...Surely you won't miss the given output...

    Actually, I did miss that. I didn't realize that the first example was output. Sorry.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: What's the problem here?
     
    Similar Threads
    How to cumulate multiple results of a method?
    2 methods into one?
    How to return two values back to the main from a for loop?
    Exception never thrown....
    Can a method that has a parameter call another method that has a paramter?