Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.awt.*;
- import static java.lang.Math.sqrt;
- public class Main {
- public class Figura
- {
- protected float pole;
- protected float obwod;
- private Color kolor;
- Figura() {};
- void rysuj()
- {
- }
- void usun()
- {
- }
- void przesun()
- {
- }
- String podajParametry()
- {
- return "";
- }
- public Figura(int p, int o, Color k)
- {
- pole = p;
- obwod = o;
- kolor = k;
- }
- public float getPole() {
- return pole;
- }
- public float getObwod() {
- return obwod;
- }
- public Color getKolor() {
- return kolor;
- }
- public void setPole(int pole) {
- this.pole = pole;
- }
- public void setObwod(int obwod) {
- this.obwod = obwod;
- }
- public void setKolor(Color kolor) {
- this.kolor = kolor;
- }
- }
- class Elipsa extends Figura
- {
- // polos wielka
- private int a;
- // polos mala
- private int b;
- // pozycje x, y dla dwoch ognisk
- private int F1x;
- private int F1y;
- private int F2x;
- private int F2y;
- // odleglosc ognisk od srodka elipsy
- private double c;
- public Elipsa(int p, int o, Color k, int a, int b, int f1x, int f1y, int f2x, int f2y, double c)
- {
- super(p, o, k);
- this.a = a;
- this.b = b;
- F1x = f1x;
- F1y = f1y;
- F2x = f2x;
- F2y = f2y;
- this.c = c;
- }
- public void odlegloscOgnisk()
- {
- c = sqrt(a * a - b *b);
- }
- public int getA() {
- return a;
- }
- public int getB() {
- return b;
- }
- public int getF1x() {
- return F1x;
- }
- public int getF1y() {
- return F1y;
- }
- public int getF2x() {
- return F2x;
- }
- public int getF2y() {
- return F2y;
- }
- public double getC() {
- return c;
- }
- public void setA(int a) {
- this.a = a;
- }
- public void setB(int b) {
- this.b = b;
- }
- public void setF1x(int f1x) {
- F1x = f1x;
- }
- public void setF1y(int f1y) {
- F1y = f1y;
- }
- public void setF2x(int f2x) {
- F2x = f2x;
- }
- public void setF2y(int f2y) {
- F2y = f2y;
- }
- public void setC(int c) {
- this.c = c;
- }
- @Override
- void rysuj() {
- super.rysuj();
- }
- @Override
- void usun() {
- super.usun();
- }
- @Override
- void przesun() {
- super.przesun();
- }
- @Override
- String podajParametry() {
- return super.podajParametry();
- }
- }
- class Wielokat extends Figura
- {
- // liczba wierzcholkow
- private int lw;
- // liczba bokow
- private int lb;
- // suma katow wewnetrznych w stopniach
- private int skw;
- public Wielokat(int p, int o, Color k, int lw, int lb, int skw)
- {
- super(p, o, k);
- this.lw = lw;
- this.lb = lb;
- this.skw = skw;
- }
- public void sumaKatowWewnetrznych()
- {
- skw = (lb - 2) * 180;
- }
- public int getLw() {
- return lw;
- }
- public int getLb() {
- return lb;
- }
- public int getSkw() {
- return skw;
- }
- public void setLw(int lw) {
- this.lw = lw;
- }
- public void setLb(int lb) {
- this.lb = lb;
- }
- public void setSkw(int lkw) {
- this.skw = skw;
- }
- Wielokat() {
- super();
- }
- @Override
- void rysuj() {
- super.rysuj();
- }
- @Override
- void usun() {
- super.usun();
- }
- @Override
- void przesun() {
- super.przesun();
- }
- }
- public class Okrag extends Elipsa
- {
- int r;
- public Okrag(int p, int o, Color k, int a, int b, int f1x, int f1y, int f2x, int f2y, double c, int r)
- {
- super(p, o, k, a, b, f1x, f1y, f2x, f2y, c);
- this.r = r;
- }
- void obliczObwod()
- {
- obwod = 2 * (float)3.14 * r;
- }
- void obliczPole()
- {
- pole = (float)3.14 * r * r;
- }
- }
- public class Trojkat extends Wielokat
- {
- int a;
- int b;
- int c;
- int h;
- public Trojkat(int p, int o, Color k, int lw, int lb, int skw, int a, int b, int c, int h)
- {
- super(p, o, k, lw, lb, skw);
- this.a = a;
- this.b = b;
- this.c = c;
- this.h = h;
- }
- void obliczObwod()
- {
- obwod = a + b + c;
- }
- void obliczPole()
- {
- pole = a * h;
- }
- }
- public class Prostokat extends Wielokat
- {
- int a;
- int b;
- public Prostokat(int p, int o, Color k, int lw, int lb, int skw, int a, int b)
- {
- super(p, o, k, lw, lb, skw);
- this.a = a;
- this.b = b;
- }
- public Prostokat(int a, int b)
- {
- this.a = a;
- this.b = b;
- }
- void obliczObwod()
- {
- obwod = a + b + a + b;
- }
- void obliczPole()
- {
- pole = a * b;
- }
- }
- public class Kwadrat extends Prostokat
- {
- int a;
- public Kwadrat(int p, int o, Color k, int lw, int lb, int skw, int a, int b, int a1)
- {
- super(p, o, k, lw, lb, skw, a, b);
- this.a = a1;
- }
- void obliczObwod()
- {
- obwod = 4 * a;
- }
- void obliczPole()
- {
- pole = a * a;
- }
- }
- public static void main(String[] args)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement