title: Obtaining Value from a Method (java)
body: <p>I have gotten this code to work out so far, but I am trying to learn how to complete this method so that it will compile the total amount of sides used and print that value on in the last print line.  The problem method is getTotalSides, I currently have it set to return 0, but I want it to return the total sides instead, meaning: mp1.getSides() + mp2.getSides() + mp3.getSides() + mp4.getSides().</p>
  
  <pre><code>public class TestParts {
  
  public static void main(String[] args) {
  
      MyPolygon mp1 = new MyPolygon();
      MyPolygon mp2 = new MyPolygon(4);
      MyPolygon mp3 = new MyPolygon(5);
      MyPolygon mp4 = new MyPolygon(6);
      System.out.println("Polygon 1 has " + mp1.getSides()
              + " sides, angles total " + mp1.getSumOfAngles());
      System.out.println("Polygon 2 has " + mp2.getSides()
              + " sides, angles total " + mp2.getSumOfAngles());
      System.out.println("Polygon 3 has " + mp3.getSides()
              + " sides, angles total " + mp3.getSumOfAngles());
      System.out.println("Polygon 4 has " + mp4.getSides()
              + " sides, angles total " + mp4.getSumOfAngles());
      System.out.println("There are " + MyPolygon.getTotalSides()
              + " total sides");
  
  }
  }
  
  class MyPolygon {
  double getSides;
  
  MyPolygon() {
      getSides = 3;
  }
  
  static double getTotalSides() {
  
      return 0;
  }
  
  double getSides() {
      // TODO Auto-generated method stub
      return getSides;
  }
  
  MyPolygon(double newGetSides) {
      getSides = newGetSides;
  }
  
  double getSumOfAngles() {
      return ((getSides - 2) * 180);
  }
  
  void setGetSides(double newGetSides) {
      getSides = newGetSides;
  }
  </code></pre>