Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package abstractions;
- /**
- * Program Name: Rectangle
- * This program will have multiple methods of setting the rectangle height and width as well as
- * methods to find area and perimeter of the rectangle.
- * @author Benger
- * Date Created: 4/4/2018
- */
- public class Rectangle {
- private double height,width;
- private static int i=1;
- private String id="R-00";
- public Rectangle() {
- height=1.0;
- width=1.0;
- i++;
- System.out.println(id+i);
- }
- public Rectangle(Rectangle r) {
- r.height=height;
- r.width=width;
- i++;
- System.out.println(id+i);
- }
- public Rectangle(double h,double w) {
- w=width;
- h=height;
- i++;
- System.out.println(id+i);
- }
- // get and sets
- void setHeight(double height) {
- height=this.height;
- }
- void setWidth(double width) {
- width=this.width;
- }
- double getHeight() {
- return height;
- }
- double getWidth() {
- return width;
- }
- public double area() {
- return height*width;
- }
- public double perimeter() {
- return 2*height+2*width;
- }
- public void thisShape() {
- System.out.println("This is a rectangle");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement