Commit 61c38882 authored by reece.french's avatar reece.french

Exercise 2 Rectangle

parent a1f0042e
public class Rectangle extends Shape{
public Rectangle() {
super();
}
//Assessment only specified 0 or 2 inputs, but unit testing required 1 input
public Rectangle(int a){
super(a);
}
public Rectangle(int i, int j) {
super(i,j);
}
@Override
public float area() {
float area = width * height;
return area;
}
@Override
public float circumference() {
float circ = width + width + height + height;
return circ;
}
@Override
public void draw(){
for (int i = 0; i < width; i++) {
if (i == 0 || i == width - 1) {
for (int j = 0; j < height; j++) {
System.out.print("-"+" ");
}
System.out.println("");
} else {
//else
for (int j = 0; j < height; j++) {
if (j == 0 || j == height - 1) {
System.out.print("|"+" ");
} else {
System.out.print(" "+" ");
}
}
System.out.println("");
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment