Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rectangle {
- //fields
- private int width;
- private int height;
- //constructors
- public Rectangle(int startWid, int startHei) {
- setDimensions(startWid, startHei);
- }
- //mutators
- public void setWidth(int newWid) {
- width = newWid;
- }
- public void setHeight(int newHeight) {
- height = newHeight;
- }
- public void setDimensions(int newWid, int newHei) {
- setWidth(newWid);
- setHeight(newHei);
- }
- //accessors
- public double area() {
- return width*height;
- }
- public double parimeter() {
- return 2*width + 2*height;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement