Jump to content

 Something great is coming! 🤖

Stay tuned for the big reveal happening here on iOSGods on the 20th of February!

The countdown has finished!

Need help with Java


Go to solution Solved by Amuyea,

19 posts in this topic

Recommended Posts

Posted

No it doesn't give me new potions and the after enemy menu doesn't appear. 

Okay. I added the code to the program.

if (enemyHP < 1){
System.out.println("---------------------------------------------------");
System.out.println(" # " + enemy + " was defeated! # ");
System.out.println(" # ");
System.out.println(" # You have" + hp + " HP left.");

Worked for me.

 

Somehow it skipped (I don't understand what this do)

if (rand.nextInt(100) > hpDrop ){
mxHPotions++;
System.out.println(" # The " + enemy + " has dropped a health potion! #");
System.out.println(" # You have" + mxHPotions + " potion(s)! #");

System.out.println("---------------------------------------------------");
int input1 = in.nextInt();
System.out.println("What now?");
System.out.println("1. Continue this maze of death untill you die...");
System.out.println("2. Realize that you have better things to do and quit!");
switch (input1){
case 1: System.out.println("So you choose death, eh... good luck on massacre of mystical creatures."); break;
case 2: System.out.println("So you choose life, eh... good luck on actual things you have to do."); break;
default:
System.out.println("---------------------------------------------------");
System.out.println("Invalid Command");
System.out.println("---------------------------------------------------");
break;

Also

case 2:
if(mxHPotions > 0)
{
hp += mxHPotions;
mxHPotions-- ;
System.out.println("---------------------------------------------------");
System.out.println("\t> You drank the potion!" + hpHealAmount + " gained!");
System.out.println("\t> You have " + hp + " HP.");
System.out.println("\t> You have " + mxHPotions + " Heath Potions left!"); 
System.out.println("---------------------------------------------------"); 
}else{
System.out.println("\t> You ran out, idiot!");
break;
} 
break;

Didn't give 50 health point to Hp just few

Posted

Okay. I added the code to the program.

if (enemyHP < 1){
System.out.println("---------------------------------------------------");
System.out.println(" # " + enemy + " was defeated! # ");
System.out.println(" # ");
System.out.println(" # You have" + hp + " HP left.");

Worked for me.

 

Somehow it skipped (I don't understand what this do)

if (rand.nextInt(100) > hpDrop ){
mxHPotions++;
System.out.println(" # The " + enemy + " has dropped a health potion! #");
System.out.println(" # You have" + mxHPotions + " potion(s)! #");

System.out.println("---------------------------------------------------");
int input1 = in.nextInt();
System.out.println("What now?");
System.out.println("1. Continue this maze of death untill you die...");
System.out.println("2. Realize that you have better things to do and quit!");
switch (input1){
case 1: System.out.println("So you choose death, eh... good luck on massacre of mystical creatures."); break;
case 2: System.out.println("So you choose life, eh... good luck on actual things you have to do."); break;
default:
System.out.println("---------------------------------------------------");
System.out.println("Invalid Command");
System.out.println("---------------------------------------------------");
break;

Also

case 2:
if(mxHPotions > 0)
{
hp += mxHPotions;
mxHPotions-- ;
System.out.println("---------------------------------------------------");
System.out.println("\t> You drank the potion!" + hpHealAmount + " gained!");
System.out.println("\t> You have " + hp + " HP.");
System.out.println("\t> You have " + mxHPotions + " Heath Potions left!"); 
System.out.println("---------------------------------------------------"); 
}else{
System.out.println("\t> You ran out, idiot!");
break;
} 
break;

Didn't give 50 health point to Hp just few

Did you learn Java in class or on your own? :p

  • Solution
Posted

Fixed HPotions used

 

case 2:
                    if(mxHPotions > 0)
                 {
                     hp += hpHealAmount; // You put mxHPotions instead of hpHealAmount
                     mxHPotions-- ;
                     System.out.println("---------------------------------------------------");
                     System.out.println("\t> You drank the potion!" + hpHealAmount + " gained!");
                     System.out.println("\t> You have " + hp + " HP.");
                     System.out.println("\t> You have " + mxHPotions + " Heath Potions left!");
                     System.out.println("---------------------------------------------------");
                 }else{
                 System.out.println("\t> You ran out, idiot!");
                 break;
                 }     
                break;
Posted

 

Fixed HPotions used

case 2:
                    if(mxHPotions > 0)
                 {
                     hp += hpHealAmount; // You put mxHPotions instead of hpHealAmount
                     mxHPotions-- ;
                     System.out.println("---------------------------------------------------");
                     System.out.println("\t> You drank the potion!" + hpHealAmount + " gained!");
                     System.out.println("\t> You have " + hp + " HP.");
                     System.out.println("\t> You have " + mxHPotions + " Heath Potions left!");
                     System.out.println("---------------------------------------------------");
                 }else{
                 System.out.println("\t> You ran out, idiot!");
                 break;
                 }     
                break;

thanks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines