title: Java switch statements outputting the same numbers
body: <p>My object randomised spawn code always sets a weapons damage to the same number every time I run the code. Although it sometimes changes between 3 (for daggers), 4, 6 and 8, but every item's damage on the map is the same. I thought it might be because there were no breaks back when I had returns at the end of each case however this wasn't the 'case' and still only outputs the same few damages.</p>
  
  <p>Example screenshot of all the sword damages as 4: <a href="http://puu.sh/hevSP/7974257751.png" rel="nofollow">http://puu.sh/hevSP/7974257751.png</a></p>
  
  <p>It's not the hard coded damage numbers because I added 'random.nextInt(5)' to each of them and they were all still the same number.</p>
  
  <p>The commented sword code at the end sets the damage to whatever I put in, so I know it's one of the switch statements causing the problem. Thanks.</p>
  
  <pre><code>    public static Object itemRoulette(String quality, int X, int Y) {
  
      Object returnItem = null;
  
      //Rolls a random item based on the input quality between 1-3.
      switch(quality)
          {
          //First tier of quality.
          case "1":
              {
              switch (random.nextInt(5) + 1)
                  {
                  case 1: {Dagger dagger = new Dagger(); World[X][Y].treasureName = "dagger"; dagger.setDamage(2); World[X][Y].treasureName = "dagger"; returnItem = dagger; break;}
                  case 2: {Potion potion = new Potion(); World[X][Y].treasureName = "potion"; potion.setType("health"); returnItem = potion; break;}
                  case 3: {Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(4); returnItem = sword; break;}
                  case 4: {Potion potion = new Potion(); World[X][Y].treasureName = "potion"; potion.setType("health"); returnItem = potion; break;}
                  case 5: {Dagger dagger = new Dagger(); World[X][Y].treasureName = "dagger"; dagger.setDamage(3); returnItem = dagger; break;}
                  }
               break;
              }
  
          //Second tier of quality
          case "2":
              {
              switch (random.nextInt(5) + 1)
                  {
                  case 1: {Dagger dagger = new Dagger(); World[X][Y].treasureName = "dagger"; dagger.setDamage(4); returnItem = dagger; break;}
                  case 2: {Potion potion = new Potion(); World[X][Y].treasureName = "potion"; potion.setType("health"); returnItem = potion; break;}
                  case 3: {Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(5); sword.setDefence(1); returnItem = sword; break;}
                  case 4: {Potion potion = new Potion(); World[X][Y].treasureName = "potion"; potion.setType("health"); returnItem = potion; break;}
                  case 5: {Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(6); sword.setDefence(1); returnItem = sword; break;}
                  }
               break;
              }
  
          //Third tier of quality.
          case "3":
              {
              switch (random.nextInt(5) + 1)
                  {
                  case 1: {Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(6); sword.setDefence(1); returnItem = sword; break;}
                  case 2: {Potion potion = new Potion(); World[X][Y].treasureName = "potion"; potion.setType("health"); returnItem = potion; break;}
                  case 3: {Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(7); sword.setDefence(1); returnItem = sword; break;}
                  case 4: {Potion potion = new Potion(); World[X][Y].treasureName = "potion"; potion.setType("health"); returnItem = potion; break;}
                  case 5: {Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(8); sword.setDefence(2); returnItem = sword; break;}
                  }
               break;
              }
  
          case "dagger":
              {
              World[X][Y].treasureName = "dagger";
              Dagger dagger = new Dagger();
              dagger.setDamage(3);
              dagger.setDefence(0);
              returnItem = dagger;
              break;
              }
  
          case "sword":
              {
              World[X][Y].treasureName = "sword";
              Sword sword = new Sword();
              sword.setDamage(6);
              sword.setDefence(1);
              returnItem = sword;
              break;
              }
          }
  
      //Sword sword = new Sword(); World[X][Y].treasureName = "sword"; sword.setDamage(40); returnItem = sword;
  
      return returnItem;
      }
  </code></pre>