title: Can I add different canvas strokes into an array?
body: <p>I am currently using a switch/case grouping to add body parts to my hangman game. As the incorrect guesses increase, a limb is added. This is forming a long switch block and was wondering if I can add each case to an array, ArrayList, TreeMap, etc. of some sort and call the body parts based on their index number? Some are strokeLines, while others are strokeOvels.</p>
  
  <p>I am not a student, but was helping a friend who is and while I coded this myself, I am stuck at a rode block with ugly code. That said, due to this being used for many CS classes (based on google searches), I am changing the numbers to X's and Y's. I am here for help, not to hand others a cheatsheet to their assignments.</p>
  
  <pre><code>public void paint(){
      GraphicsContext g = gameCanvas.getGraphicsContext2D();
  
      switch (newGame.getIncGuessMade()){
          case 0:{
              //gallows...
              g.strokeLine(X,Y,X,Y);
              g.strokeLine(X,Y,X,Y);
              g.strokeLine(X,Y,X,Y);
              g.strokeLine(X,Y,X,Y);
              g.strokeLine(X,Y,X,Y);
              g.strokeLine(X,Y,X,Y);
              g.strokeLine(X,Y,X,Y);
          }
          break;
          case 1: g.strokeOval(X,Y,X,Y);     //head
              break;
          case 2: g.strokeLine(X,Y,X,Y);     //chest
              break;
          case 3: g.strokeLine(X,Y,X,Y);     //Right Arm
              break;
          case 4: g.strokeLine(X,Y,X,Y);     //Left Arm
              break;
          case 5: g.strokeLine(X,Y,X,Y);     //Right Leg
              break;
          case 6: g.strokeLine(X,Y,X,Y);     //Left Leg
              break;
          case 7: g.strokeOval(X,Y,X,Y);     //Right Eye
              break;
          case 8: g.strokeOval(X,Y,X,Y);     //Left Eye
              break;
      }
  
  }
  </code></pre>