Commit c8182b71 authored by Suleman Hussain's avatar Suleman Hussain

finished

parent 853f88a2
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
public class App { public class App {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Shape shape1 = new Rectangle(5,10); Shape shape1 = new Rectangle(3,8);
shape1.draw(); shape1.draw();
} }
} }
No preview for this file type
...@@ -3,6 +3,7 @@ public class Rectangle extends Shape{ ...@@ -3,6 +3,7 @@ public class Rectangle extends Shape{
public int width; public int width;
public int height; public int height;
public int getWidth() { public int getWidth() {
return this.width; return this.width;
} }
...@@ -10,23 +11,32 @@ public class Rectangle extends Shape{ ...@@ -10,23 +11,32 @@ public class Rectangle extends Shape{
public void setWidth(int width){ public void setWidth(int width){
this.width=width; this.width=width;
} }
public int getHeight() { public int getHeight() {
return this.height; return this.height;
} }
public void setHeight(int height) { public void setHeight(int height) {
this.height=height; this.height=height;
} }
public Rectangle() { public Rectangle() {
super(); super();
this.setHeight(4); this.setHeight(4);
this.setWidth(3); this.setWidth(3);
} }
public Rectangle(int i,int j) { public Rectangle(int i,int j) {
super(); super();
this.setHeight(height); this.setHeight(j);
this.setWidth(width); this.setWidth(i);
} }
public Rectangle(int i) {
super();
this.setWidth(i);
}
@Override @Override
public void draw() { public void draw() {
int width = this.getWidth(); int width = this.getWidth();
......
No preview for this file type
abstract public class Shape { abstract public class Shape {
protected int size; protected int size;
protected int width;
protected int height;
abstract public void draw(); abstract public void draw();
abstract public float area(); abstract public float area();
abstract public float circumference(); abstract public float circumference();
abstract public int getWidth();
abstract public int getHeight();
abstract public void setHeight(int height);
abstract public void setWidth(int width);
public int getSize() { return size; } public int getSize() { return size; }
public void setSize(int size) { this.size = size; } public void setSize(int size) { this.size = size; }
public Shape(){ public Shape(){
this.size = 3; this.size = 3;
} }
......
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