Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rectangle {
- private double length;
- private double width;
- Rectangle(double length, double width) {
- this.length = length;
- this.width = width;
- }
- public double getLength() {
- return this.length;
- }
- public void setLength(double length) {
- if((length >= 1.0) && (length <= 50.0)) {
- this.length = length;
- }
- else{
- this.length = 1.0;
- }
- }
- public double getWidth() {
- return this.width;
- }
- public void setWidth(double width) {
- if((width >= 1.0) && (width <= 50.0))
- this.width = width;
- else{
- this.width = 1.0;
- }
- }
- public double getCalcPrimeter(){
- return 2 *(this.getLength() * this.getWidth());
- }
- public double getArea(){
- return (this.getWidth() * this.getLength());
- }
- @Override
- public String toString() {
- return "Rectangle [length=" + length + ", width=" + width + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement