Advertisement
mikolajmki

java_lab5

Nov 16th, 2021
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.50 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.awt.*;
  4.  
  5. import static java.lang.Math.sqrt;
  6.  
  7. public class Main {
  8.  
  9.     public class Figura
  10.     {
  11.         protected float pole;
  12.         protected float obwod;
  13.         private Color kolor;
  14.  
  15.         Figura() {};
  16.  
  17.         void rysuj()
  18.         {
  19.  
  20.         }
  21.         void usun()
  22.         {
  23.  
  24.         }
  25.         void przesun()
  26.         {
  27.  
  28.         }
  29.         String podajParametry()
  30.         {
  31.             return "";
  32.         }
  33.         public Figura(int p, int o, Color k)
  34.         {
  35.             pole = p;
  36.             obwod = o;
  37.             kolor = k;
  38.         }
  39.  
  40.         public float getPole() {
  41.             return pole;
  42.         }
  43.  
  44.         public float getObwod() {
  45.             return obwod;
  46.         }
  47.  
  48.         public Color getKolor() {
  49.             return kolor;
  50.         }
  51.  
  52.         public void setPole(int pole) {
  53.             this.pole = pole;
  54.         }
  55.  
  56.         public void setObwod(int obwod) {
  57.             this.obwod = obwod;
  58.         }
  59.  
  60.         public void setKolor(Color kolor) {
  61.             this.kolor = kolor;
  62.         }
  63.     }
  64.  
  65.  
  66.     class Elipsa extends Figura
  67.     {
  68.         // polos wielka
  69.         private int a;
  70.         // polos mala
  71.         private int b;
  72.         // pozycje x, y dla dwoch ognisk
  73.         private int F1x;
  74.         private int F1y;
  75.         private int F2x;
  76.         private int F2y;
  77.         // odleglosc ognisk od srodka elipsy
  78.         private double c;
  79.  
  80.         public Elipsa(int p, int o, Color k, int a, int b, int f1x, int f1y, int f2x, int f2y, double c)
  81.         {
  82.             super(p, o, k);
  83.             this.a = a;
  84.             this.b = b;
  85.             F1x = f1x;
  86.             F1y = f1y;
  87.             F2x = f2x;
  88.             F2y = f2y;
  89.             this.c = c;
  90.         }
  91.  
  92.         public void odlegloscOgnisk()
  93.         {
  94.             c = sqrt(a * a - b *b);
  95.         }
  96.  
  97.         public int getA() {
  98.             return a;
  99.         }
  100.  
  101.         public int getB() {
  102.             return b;
  103.         }
  104.  
  105.         public int getF1x() {
  106.             return F1x;
  107.         }
  108.  
  109.         public int getF1y() {
  110.             return F1y;
  111.         }
  112.  
  113.         public int getF2x() {
  114.             return F2x;
  115.         }
  116.  
  117.         public int getF2y() {
  118.             return F2y;
  119.         }
  120.  
  121.         public double getC() {
  122.             return c;
  123.         }
  124.  
  125.         public void setA(int a) {
  126.             this.a = a;
  127.         }
  128.  
  129.         public void setB(int b) {
  130.             this.b = b;
  131.         }
  132.  
  133.         public void setF1x(int f1x) {
  134.             F1x = f1x;
  135.         }
  136.  
  137.         public void setF1y(int f1y) {
  138.             F1y = f1y;
  139.         }
  140.  
  141.         public void setF2x(int f2x) {
  142.             F2x = f2x;
  143.         }
  144.  
  145.         public void setF2y(int f2y) {
  146.             F2y = f2y;
  147.         }
  148.  
  149.         public void setC(int c) {
  150.             this.c = c;
  151.         }
  152.  
  153.         @Override
  154.         void rysuj() {
  155.             super.rysuj();
  156.         }
  157.  
  158.         @Override
  159.         void usun() {
  160.             super.usun();
  161.         }
  162.  
  163.         @Override
  164.         void przesun() {
  165.             super.przesun();
  166.         }
  167.  
  168.         @Override
  169.         String podajParametry() {
  170.             return super.podajParametry();
  171.         }
  172.     }
  173.  
  174.  
  175.     class Wielokat extends Figura
  176.     {
  177.         // liczba wierzcholkow
  178.         private int lw;
  179.         // liczba bokow
  180.         private int lb;
  181.         // suma katow wewnetrznych w stopniach
  182.         private int skw;
  183.  
  184.         public Wielokat(int p, int o, Color k, int lw, int lb, int skw)
  185.         {
  186.             super(p, o, k);
  187.             this.lw = lw;
  188.             this.lb = lb;
  189.             this.skw = skw;
  190.         }
  191.  
  192.         public void sumaKatowWewnetrznych()
  193.         {
  194.             skw = (lb - 2) * 180;
  195.         }
  196.  
  197.         public int getLw() {
  198.             return lw;
  199.         }
  200.  
  201.         public int getLb() {
  202.             return lb;
  203.         }
  204.  
  205.         public int getSkw() {
  206.             return skw;
  207.         }
  208.  
  209.         public void setLw(int lw) {
  210.             this.lw = lw;
  211.         }
  212.  
  213.         public void setLb(int lb) {
  214.             this.lb = lb;
  215.         }
  216.  
  217.         public void setSkw(int lkw) {
  218.             this.skw = skw;
  219.         }
  220.  
  221.         Wielokat() {
  222.             super();
  223.         }
  224.  
  225.         @Override
  226.         void rysuj() {
  227.             super.rysuj();
  228.         }
  229.  
  230.         @Override
  231.         void usun() {
  232.             super.usun();
  233.         }
  234.  
  235.         @Override
  236.         void przesun() {
  237.             super.przesun();
  238.         }
  239.     }
  240.  
  241.     public class Okrag extends Elipsa
  242.     {
  243.         int r;
  244.  
  245.         public Okrag(int p, int o, Color k, int a, int b, int f1x, int f1y, int f2x, int f2y, double c, int r)
  246.         {
  247.             super(p, o, k, a, b, f1x, f1y, f2x, f2y, c);
  248.             this.r = r;
  249.         }
  250.  
  251.         void obliczObwod()
  252.         {
  253.             obwod = 2 * (float)3.14 * r;
  254.         }
  255.  
  256.         void obliczPole()
  257.         {
  258.             pole = (float)3.14 * r * r;
  259.         }
  260.     }
  261.  
  262.     public class Trojkat extends Wielokat
  263.     {
  264.         int a;
  265.         int b;
  266.         int c;
  267.         int h;
  268.  
  269.         public Trojkat(int p, int o, Color k, int lw, int lb, int skw, int a, int b, int c, int h)
  270.         {
  271.             super(p, o, k, lw, lb, skw);
  272.             this.a = a;
  273.             this.b = b;
  274.             this.c = c;
  275.             this.h = h;
  276.         }
  277.  
  278.         void obliczObwod()
  279.         {
  280.             obwod = a + b + c;
  281.         }
  282.  
  283.         void obliczPole()
  284.         {
  285.             pole = a * h;
  286.         }
  287.     }
  288.  
  289.     public class Prostokat extends Wielokat
  290.     {
  291.         int a;
  292.         int b;
  293.  
  294.         public Prostokat(int p, int o, Color k, int lw, int lb, int skw, int a, int b)
  295.         {
  296.             super(p, o, k, lw, lb, skw);
  297.             this.a = a;
  298.             this.b = b;
  299.         }
  300.  
  301.         public Prostokat(int a, int b)
  302.         {
  303.             this.a = a;
  304.             this.b = b;
  305.         }
  306.  
  307.         void obliczObwod()
  308.         {
  309.             obwod = a + b + a + b;
  310.         }
  311.  
  312.         void obliczPole()
  313.         {
  314.             pole = a * b;
  315.         }
  316.     }
  317.  
  318.     public class Kwadrat extends Prostokat
  319.     {
  320.         int a;
  321.  
  322.         public Kwadrat(int p, int o, Color k, int lw, int lb, int skw, int a, int b, int a1)
  323.         {
  324.             super(p, o, k, lw, lb, skw, a, b);
  325.             this.a = a1;
  326.         }
  327.  
  328.         void obliczObwod()
  329.         {
  330.             obwod = 4 * a;
  331.         }
  332.  
  333.         void obliczPole()
  334.         {
  335.             pole = a * a;
  336.         }
  337.     }
  338.  
  339.     public static void main(String[] args)
  340.     {
  341.  
  342.     }
  343. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement