Commit 6c07dbfb authored by a-j.towse's avatar a-j.towse

Final Commit

parent 59978554
No preview for this file type
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 Rectangle extends Shape{
public Rectangle(){
setWidth(3);
setHeight(4);
}
public Rectangle(int x, int y){
setWidth(x);
setHeight(y);
}
@Override
public float area(){
float area = width * height;
return area;
}
@Override
public float circumference(){
float circ = (width*2) + (height*2);
return circ;
}
@Override
public void draw(){
}
}
abstract public class Shape {
protected int size;
protected int width;
protected int height;
abstract public void draw();
abstract public float area();
......@@ -15,6 +17,25 @@ abstract public class Shape {
public Shape(int size){
this.size = size;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public void setWidth(int width){
this.width = width;
}
public void setHeight(int height){
this.height = height;
}
}
......@@ -8,16 +8,32 @@ public class Square extends Shape{
super(x);
}
@Override
public float area(){
return(size*size);
}
@Override
public float circumference(){
return(size*4);
}
public void Draw(){
@Override
public void draw(){
for (int loop1=0; loop1<size; loop1++){
System.out.print("--");
}
System.out.println();
for (int loop2=0; loop2<(size); loop2++){
System.out.print("|");
for (int loop3=0; loop3<(size-1); loop3++){
System.out.print(" ");
}
System.out.println("|");
}
for (int loop4=0; loop4<size; loop4++){
System.out.print("--");
}
}
}
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