Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package figury;
- public class Prostokat {
- private int xA;
- private int yA;
- private int xB;
- private int yB;
- private int xC;
- private int yC;
- private int xD;
- private int yD;
- public Prostokat(int xA, int yA, int xB, int yB, int xC, int yC, int xD, int yD) {
- this.xA = xA;
- this.xB = xB;
- this.xC = xC;
- this.xD = xD;
- this.yA = yA;
- this.yB = yB;
- this.yC = yC;
- this.yD = yD;
- }
- public Prostokat() {
- this(0,0, 0,1, 1,1, 1,0);
- }
- private double obliczOdcinek(int x1, int y1, int x2, int y2) {
- return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
- }
- public double podajPole() {
- double bok1;
- double bok2;
- bok1 = obliczOdcinek(xA, yA, xB, yB);
- bok2 = obliczOdcinek(xA, yA, xD, yD);
- return bok1*bok2;
- }
- public void rysuj() {
- System.out.println("PROSTOKAT:");
- System.out.println("Wspolrzedne A: (" + xA + "," + yA + "); ");
- System.out.println("Wspolrzedne B: (" + xB + "," + yB + "); ");
- System.out.println("Wspolrzedne C: (" + xC + "," + yC + "); ");
- System.out.println("Wspolrzedne D: (" + xD + "," + yD + "); ");
- System.out.println("Dlugosc bokow: " + obliczOdcinek(xA,yA, xB,yB) + " oraz " + obliczOdcinek(xB,yB, xC,yC));
- //Dokonczyc wspolrzedne oraz dl. bokow
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement