Last active
September 12, 2018 19:11
-
-
Save themisir/734677b4ac80f9f030776fa1fd316ea0 to your computer and use it in GitHub Desktop.
This file contains 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 float x; | |
public float y; | |
public float width; | |
public float height; | |
public float left() { | |
return this.x; | |
} | |
public float top() { | |
return this.y; | |
} | |
public float right() { | |
return this.x + this.width; | |
} | |
public float bottom() { | |
return this.y + this.height; | |
} | |
public boolean contains(float x, float y) { | |
return x >= left() && x <= right() && y >= top() && y <= bottom(); | |
} | |
public void set(float x, float y, float width, float height) { | |
this.x = x; | |
this.y = y; | |
this.width = width; | |
this.height = height; | |
} | |
public Rectangle(float x, float y, float width, float height) { | |
this.set(x, y, width, height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment