Saturday, September 8, 2012

Making the Triangle Class

Hi all,

Hope you're having a nice weekend.

So I've had the chance to see some of you working on the Triangle class.  Neat stuff.  Looks like many of you are making good progress.  It's exciting for me to see how far you've already come in only a few short weeks.  You have no idea how much potential you have right now to do some amazing things with this stuff... you will soon see.

For anyone who could use a little boost towards getting the assignment done right, here's a skeleton of how the Triangle class should look.  I'm leaving out the body of each of the methods here, so you'll need to add them in to have the assignment work as intended.  Remember to use the Circle class as a starting point.  It was intended to help you get through this with minimal stress.  Remember, too, that you'll also need to write the complete TriangleTester program according to the directions on my DHS web site... DON'T FORGET ANY PARTS OF IT!

public class Triangle
{
   //PART I:  INSTANCE VARIABLES
   private double base;
   private double height;

   //PART II:  CONSTRUCTORS
   public Triangle()
   {
   }

   public Triangle(double b, double h)
   {
   }

   //PART III:  ACCESSORS
   public double getBase()
   {
   }

   public double getHeight()
   {
   }

   //PART IV:  MUTATORS
   public void setBase(double b)
   {
   }

   public void setHeight(double h)
   {
   }

   //PART V:  GETAREA
   public double getArea()
   {
       //DON'T FORGET THAT INTEGER DIVISION THING
       //I SHOWED YOU AT THE END OF THE PERIOD!!
   }

   //PART VI:  TOSTRING
   public String toString()
   {
   }
}

Hope this helps... let me (or Spencer, Daniel, Adam, Stephen, or any of the other veteran students) know if you need any extra guidance.

See you all soon,
Mr. Svetlik

No comments:

Post a Comment