title: My method won't take an object
body: <p>I'm making a dice rolling program to simulate rolling a die a given number of times.  First I create a Die object with a given number of sides, and then use that Die in a roll method that simulates the number of time it will be rolled.  </p>
  
  <p>Can someone clarify?</p>
  
  <pre><code>public class Die {
  
      private int numSides;
  
      public Die() {
          numSides = 0;
      }
  
      public Die(int sides){
          numSides = sides; 
      }
  
      public void setSides(int sides){
          numSides = sides;
      }
  
      public int getSides(){
      return numSides;
      }
  }
  
  public class DiceRoll {
  
      public static void main(String []args){
  
  
          Die sixSides = new Die(6);
          sixSides.roll(7); //ERROR: "the method is undefined for type Die" 
  
  
          //Prints out the roll outcomes for the given die
          public void roll(int numTimes){
              for (int i = 0; i &lt; numTimes; i++){
                  int rand = 1 + (int)(Math.random()*this.getSides());
                  System.out.println(rand);
              //ERROR: "cannot use THIS in a static context".
  
              }
          }   
      }
  }
  </code></pre>
  
  <p>The Error is:</p>
  
  <blockquote>
    <p>the method is undefined for type Die
    cannot use this in a static context</p>
  </blockquote>