aspose file tools*
The moose likes Beginning Java and the fly likes seemingly identical code producing 2 different outcomes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "seemingly identical code producing 2 different outcomes." Watch "seemingly identical code producing 2 different outcomes." New topic
Author

seemingly identical code producing 2 different outcomes.

brent carter
Ranch Hand

Joined: Dec 15, 2011
Posts: 34
In this mock RPG i made, I allow the option of attack or magic. in the fighter class...the magic stat is less than the strength stat and yet the magic attacks do significantly more than attack attacks when you actually run the program and I am mystified. Here is the snippet of code. (I wanted to attach the program but you cannot attach zip files. Is there a way to make some kind of special file with eclipse that another eclipse editor can open the entire project?)


and here is the stats page:



Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

You'll have a better chance of getting help if you can provide an SSCCE that has just enough code to demonstrate your problem and nothing else, and show clearly and precisely what behavior your expected and what you saw instead.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

brent carter wrote:Is there a way to make some kind of special file with eclipse that another eclipse editor can open the entire project?)


There's no need for that. Folks won't be inclined to deal with an entire project anyway. You need to narrow down the source of the problem enough that a small snippet of code (ideally an SSCCE) is sufficient to demonstrate it.
Thomas Kennedy
Ranch Hand

Joined: Jan 20, 2008
Posts: 137
Look at line 50, compare it to line 49.

Repetition is a big source of bugs. Can you think of a way to avoid repeating 'oldlady' and 'hippie' all over the place?


Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

It's the dreaded Copy-Paste-Forget-To-Change antipattern!
brent carter
Ranch Hand

Joined: Dec 15, 2011
Posts: 34
Guys what I have recently been learning to do is make a generic class and extending other classes of different enemies from the first class, making it so i only have to write everything one time and it makes the code look much nicer as well. Now if i could only stop playing the new star wars game I may actually get some work done!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: seemingly identical code producing 2 different outcomes.