dbrown
Class RTModel

java.lang.Object
  extended by dbrown.RTModel

public class RTModel
extends java.lang.Object

The right triangle model. Allows users to update the base and height separately.

Version:
2006-11-01
Author:
David Brown from Byron Weber-Becker

Field Summary
private  double base
          The inital size of the base.
private  double height
          The initial size of the height.
static double MAX_SIDE
          The maximum size of each of the two non-hypotenuse sides of the triangle.
private  java.util.ArrayList<IView> views
          A collection of views of the model.
 
Constructor Summary
RTModel()
           
 
Method Summary
 void addView(IView newView)
          Adds a view to the model's collection of views.
 void deleteView(IView oldView)
          Removes a view from the model's collection of views.
 double getBase()
          Returns the value of the model's base.
 double getHeight()
          Returns the value of the model's height.
 double getHypotenuse()
          Calculates and returns the hypotenuse.
 void setBase(double newBase)
          Assigns a value to the model's base and updates all views accordingly.
 void setHeight(double newHeight)
          Assigns a value to the model's height and updates all views accordingly.
private  void updateViews()
          Updates all views attached to the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SIDE

public static final double MAX_SIDE
The maximum size of each of the two non-hypotenuse sides of the triangle.

See Also:
Constant Field Values

base

private double base
The inital size of the base.


height

private double height
The initial size of the height.


views

private java.util.ArrayList<IView> views
A collection of views of the model.

Constructor Detail

RTModel

public RTModel()
Method Detail

addView

public void addView(IView newView)
Adds a view to the model's collection of views.

Parameters:
newView - The view to add to the model's collection of views.

deleteView

public void deleteView(IView oldView)
Removes a view from the model's collection of views.

Parameters:
oldView - The view to be removed from the model's collection of views.

getBase

public double getBase()
Returns the value of the model's base.

Returns:
the value of the model's base.

getHeight

public double getHeight()
Returns the value of the model's height.

Returns:
the value of the model's height.

getHypotenuse

public double getHypotenuse()
Calculates and returns the hypotenuse.

Returns:
the hypotenuse.

setBase

public void setBase(double newBase)
Assigns a value to the model's base and updates all views accordingly.

Parameters:
newBase - The base value to set.

setHeight

public void setHeight(double newHeight)
Assigns a value to the model's height and updates all views accordingly.

Parameters:
newHeight - The height value to set.

updateViews

private void updateViews()
Updates all views attached to the model.