• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Variable not decreased

 
Greenhorn
Posts: 5
Mac C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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;
 
Ranch Hand
Posts: 375
1
Python Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 375
1
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And do use a proper heading for your post..
See UseAMeaningfulSubjectLine
 
Isaac Skelton
Greenhorn
Posts: 5
Mac C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic