mercredi 15 novembre 2017

My "if statements" do not run, even though the parameters are true

Ok, so my code will compile as if there are no errors, but then the code that should be executed will not truly run. Please help.

public static void newGameCheck()   {
    String newCharacter = scan.next();
    if (newCharacter.equals("New game"))    {
    //more code here, but it does not get executed for some reason
    }

And another example is here:

public static void warriorTurn()    {
    if (warriorAlive==true) {
        etut.choosingTarget();
        int target= scan.nextInt();
        System.out.println("Now type in which ability you want him to use, make sure to use capitals");
        warrior_Weapons_and_Abilities();


String ability= scan.next();
            if (ability.equals("Anduril, Foe of Terror"))   {
                int damage= 100+((int) (Math.random()*50));
                etut.loseHealth(target, damage);
                mana2=mana2-0;
                etut.displayHealth(target);         
            }
            else if (ability.equals("Aethereal Blades"))    {


int damage= 250+((int) (Math.random()*100));
                etut.loseHealth(target, damage);
                mana2=mana2-2;
                etut.displayHealth(target);             
            }
            else if (ability.equals("Potion"))  {
            health2=health2+100;
            mana=mana-0;
            etut.displayHealth(target);




    }

Here^, whenever I type in the ability name, the code still will not execute

Aucun commentaire:

Enregistrer un commentaire