Skip to content

Commit 9067d58

Browse files
committed
adding source
1 parent d0faf74 commit 9067d58

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Rectangle.java

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Rectangle {
2+
public int length;
3+
public int width;
4+
5+
public Rectangle(int length, int width) {
6+
this.length = length;
7+
this.width = width;
8+
}
9+
10+
public int getArea() {
11+
return length * width;
12+
}
13+
14+
public int getPerimeter() {
15+
return 2 * (length + width);
16+
}
17+
}

src/Rectangulator.java

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class Rectangulator {
2+
public static void main(String[] args) {
3+
int length = Integer.parseInt(args[0]);
4+
int width = Integer.parseInt(args[1]);
5+
6+
Rectangle myRectangle = new Rectangle(length, width);
7+
8+
String output = String.format("*** Your Rectangle ***\n\nLength: %d\nWidth: %d\nArea: %d\nPerimeter: %d\n\n", myRectangle.length, myRectangle.width, myRectangle.getArea(), myRectangle.getPerimeter());
9+
10+
System.out.println(output);
11+
}
12+
}

0 commit comments

Comments
 (0)