File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes C / C++ and the fly likes Variable not decreased Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "Variable not decreased" Watch "Variable not decreased" New topic
Author

Variable not decreased

Isaac Skelton
Greenhorn

Joined: Sep 06, 2012
Posts: 5



Output section in code:

Your Life 100
There Life 100

Your Attack List
1) Punch: UNLIMITED
2) Combo Punch: 2
3) Life Drainer: 1
4) Heal Yourself: 1
5) Squash: 0
1
Your Life 100
There Life 100

Your Attack List
1) Punch: UNLIMITED
2) Combo Punch: 2
3) Life Drainer: 1
4) Heal Yourself: 1
5) Squash: 0

I have only displayed one section of this applications output because thats the bit with a problem. As you can see the life stays the same even thought I have punched which is meant to take away 5 from there life, but it isn't. How can I resolve this problem. I have supplied you with all the source code that I have done and urgently wan't a solution so please help. The line that I think is the main for this problem is...
theirLifeLineAmount = theirLifeLineAmount - 5;
R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 367
    
    1

Hello Isaac, Welcome to Code Ranch
Isaac Skelton wrote:


You see that you have declared yourLifeLineAmount and theirLifeLineAmount inside attackSection
So every time goto attackSection in invoked in that else part.. These variables are re-initialized to 100 and the earlier changed value is not reflected..

So, you have to work around with this problem..
R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 367
    
    1

And do use a proper heading for your post..
See UseAMeaningfulSubjectLine
Isaac Skelton
Greenhorn

Joined: Sep 06, 2012
Posts: 5

Thanks for the reply, someone else gave me the answer yesterday so the problem has now been solved. All I need to work on now are enemy attacks and some other little things.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variable not decreased
 
Similar Threads
answer for the program
Divisibity Test Question
Vending Machine Program - Not giving correct change. Need help desperatly!
Vending Machine Program - Not giving correct change. Need help desperatly!
Conversion help plz!!!