Skip to content

Instantly share code, notes, and snippets.

@annibuliful
Last active February 4, 2018 06:10
Show Gist options
  • Save annibuliful/a7544f8f15fb9d92b64b551fb5c943a1 to your computer and use it in GitHub Desktop.
Save annibuliful/a7544f8f15fb9d92b64b551fb5c943a1 to your computer and use it in GitHub Desktop.
class Rectangle {
public int width;
public int height;
public static void main(String[] agrs){
Rectangle myrect = new Rectangle();
myrect.setWidth(50);
myrect.setWidth(40);
System.out.println("myRect's area is " + myrect.area());
}
Rectangle(){
this.width = 0;
this.height = 0;
}
public void setHeight(int height) {
this.height = height;
}
public void setWidth(int width) {
this.width = width;
}
public int area(){
return this.width * this.height;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment