All pastes #163708 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-09-07 20:13 UTC
rendered paste body
public class Rectangle{
        // private data fields
        private double length;
        private double width;

        //constructor
        public Rectangle( double len, double w)
        {
                length = len;
                width = w;
                System.out.println("In Rectangle Constructor!\n");
        }

        //public method

        public void setLength(double len)
        {
                length = len; //assign len to field length
        }

        public void setWidth(double wid)
        {
                width = wid; //assign wid to field width
        }

        public double getLength()
        {
                return length;
        }

        public double getWidth()
        {
                return width;
        }

        public double getArea()
        {
                return (length * width);
        }
}