• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

seemingly identical code producing 2 different outcomes.

 
brent carter
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 137
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the dreaded Copy-Paste-Forget-To-Change antipattern!
 
brent carter
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic