Commit 5bae5605 authored by jinny.wilkin's avatar jinny.wilkin

upload1

parent 7d98d415
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -2,5 +2,8 @@ public class App {
public static void main(String[] args) throws Exception {
Shape shape1 = new Triangle(3);
shape1.draw();
Shape shape2 = new Square(3);
shape2.draw();
}
}
public class Square extends Shape{
public Square() {
super();
}
public Square(int i) {
super(i);
}
public void draw(){
for (int i = 0; i <= size+1; i++) {
if (i == 0 || i == size+1) {
for (int j = 0; j < size; j++) {
System.out.print("--");
}
System.out.println(""); //enter a new line
} 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(""); //enter a new line
}
}
}
//@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;
}
}
No preview for this file type
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