Commit a1f0042e authored by reece.french's avatar reece.french

Exercise 2 Square

parent 6f8a4e4b
public class Square extends Shape{
public Square() {
super();
}
public Square(int i) {
super(i);
}
@Override
public float area() {
float fSize = size;
float area = fSize * fSize;
return area;
}
@Override
public float circumference() {
float fSize = size;
float circ = fSize + fSize +fSize +fSize;
return circ;
}
@Override
public void draw(){
for (int i = 0; i < size; i++) {
if (i == 0 || i == size - 1) {
for (int j = 0; j < size; j++) {
System.out.print("-"+" ");
}
System.out.println("");
} else {
//else
for (int j = 0; j < size; j++) {
if (j == 0 || j == size - 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