Last active
February 4, 2018 06:10
-
-
Save annibuliful/a7544f8f15fb9d92b64b551fb5c943a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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