Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Prostokat {
- Punkt lg;
- Punkt pd;
- Prostokat() {
- this.lg = new Punkt(0, 1);
- this.pd = new Punkt(1, 0);
- }
- Prostokat(Punkt p1, Punkt p2) {
- this.lg = p1;
- this.pd = p2;
- }
- Prostokat(int x1, int y1, int x2, int y2) {
- this.lg = new Punkt(x1, y1);
- this.pd = new Punkt(x2, y2);
- }
- Prostokat(Prostokat pr) {
- this.lg = new Punkt(pr.lg);
- this.pd = new Punkt(pr.pd);
- }
- public Punkt getLg() {
- return this.lg;
- }
- public void setLg(Punkt lg) {
- this.lg = lg;
- }
- public Punkt getPd() {
- return this.pd;
- }
- public void setPd(Punkt pd) {
- this.pd = pd;
- }
- int pole() {
- int a = Math.abs(this.lg.pobierzX() - this.pd.pobierzX());
- int b = Math.abs(this.lg.pobierzY() - this.pd.pobierzY());
- return a * b;
- }
- int obwod() {
- int a = Math.abs(this.lg.pobierzX() - this.pd.pobierzX());
- int b = Math.abs(this.lg.pobierzY() - this.pd.pobierzY());
- return 2 * a + 2 * b;
- }
- public String toString() {
- return "(" + this.lg.pobierzX() + ", " + this.lg.pobierzY() + "), " + "(" + this.pd.pobierzX() + ", " + this.pd.pobierzY() + ")";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement