/* Author : Michael Robinson modified from book Program : Building.java Purpose : To present Classes and Objects An object is an instance of a class, a clone of a class. An object contains methods and data called object's fields. Objects are not stand alone programs and can be re-used like methods. Updated : July 24, 2099 */ public class Building { private double length; //creates global variable private double width; //creates global variable //this first constructor does no accept parameters public Building() { length = 15; width = 15; } //this constructor accepts two ints public Building( int len, int w ) { length = len; //len gets assigned to length width = w; //w gets assigned to width } //this constructor accepts one double and one int public Building( double length, int width ) { //local length gets assigned to the global length this.length = length; //local width gets assigned to the global width this.width = width; } //this constructor accepts one int and one double public Building( int len, double w ) { length = len; //local len gets assigned to the global length width = w; //local w gets assigned to the global width } //this constructor accepts two doubles public Building( double len, double w ) { length = len; //local len gets assigned to the global length width = w; //local w gets assigned to the global width } //Mutators (sets) **************************************** //The setLength method stores a value in the length field. public void setLength( double len ) { length = len; //local len gets assigned to the global length } //The setWidth method stores a value in the width field. public void setWidth( double w ) { width = w; //local w gets assigned to the global width } //Accessors (gets) **************************************** //The getLength method returns a Rectangle object's length. public double getLength() { return length; //return the value of the global length } //The getWidth method returns a Rectangle object's width. public double getWidth() { return width; //return the value of the global width } //The getArea method returns a Rectangle object's area. public double getArea() { return length * width; //returns the product of length*width. } }//end public class Building