Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Rysownik;
- public class Kwadrat {
- public double a;
- public String typ = "Kwadrat";
- public Kwadrat(double a) {
- this.a = a;
- }
- }
- public class Prostokat {
- public double a;
- public double b;
- public String typ = "Prostokat";
- public Prostokat(double a, double b) {
- this.a = a;
- this.b = b;
- }
- }
- public class Trojkat {
- public double a;
- public double h;
- public String typ = "Trojkat";
- public Trojkat(double a, double h) {
- this.a = a;
- this.h = h;
- }
- }
- public class Rysownik {
- public void Rysuj(Kwadrat kwadrat) {
- int Xposition;
- for(Xposition = 0; Xposition < kwadrat.a; Xposition++)
- {
- System.out.print("X");
- }
- for(int Yposition = 0; Yposition < kwadrat.a-1; Yposition++)
- {
- System.out.println();
- System.out.print("X");
- for(Xposition=0;Xposition < kwadrat.a-2;Xposition++)
- {
- System.out.print(".") ;
- }
- System.out.print("X");
- }
- System.out.println();
- for(Xposition = 0; Xposition < kwadrat.a; Xposition++)
- {
- System.out.print("X");
- }
- }
- public void Rysuj(Prostokat prostokat) {
- int Xposition;
- for(Xposition = 0; Xposition < prostokat.a; Xposition++)
- {
- System.out.print("X");
- }
- for(int Yposition = 0; Yposition < prostokat.b-1; Yposition++)
- {
- System.out.println();
- System.out.print("X");
- for(Xposition=0;Xposition < prostokat.a-2;Xposition++)
- {
- System.out.print(".") ;
- }
- System.out.print("X");
- }
- System.out.println();
- for(Xposition = 0; Xposition < prostokat.a; Xposition++)
- {
- System.out.print("X");
- }
- }
- public void Rysuj(Trojkat trojkat) {
- double MiddlePoint = trojkat.a / 2;
- int TempNumber;
- for (TempNumber = 0; TempNumber < Math.floor(MiddlePoint); TempNumber++)
- {
- System.out.print(" ");
- }
- System.out.print("X");
- System.out.println();
- int PrevLeftWall = (int) MiddlePoint;
- for (int LinePoision = 1; LinePoision < trojkat.h - 1; LinePoision++)
- {
- double drawDone = (double) LinePoision / (trojkat.h - 1);
- int LeftWall = (int) Math.floor(MiddlePoint - MiddlePoint * drawDone);
- int RightWall = (int) Math.ceil(MiddlePoint - (MiddlePoint * drawDone * -1));
- int HowManyX = PrevLeftWall - LeftWall;
- for (TempNumber = 0; TempNumber < LeftWall; TempNumber++)
- {
- System.out.print(" ");
- }
- TempNumber = HowManyX;
- HowManyX = 0;
- do
- {
- HowManyX++;
- TempNumber--;
- System.out.print("X");
- } while (TempNumber > 0);
- for (TempNumber = LeftWall + HowManyX; TempNumber < RightWall - HowManyX; TempNumber++)
- {
- System.out.print(".");
- }
- for (TempNumber = HowManyX; TempNumber > 0; TempNumber--)
- {
- System.out.print("X");
- }
- System.out.println();
- PrevLeftWall = LeftWall;
- }
- for (TempNumber = 0; TempNumber < trojkat.a; TempNumber++)
- {
- System.out.print("X");
- }
- System.out.println();
- }
- }
- public class JavaApplication1 {
- public static void main(String[] args) {
- Rysownik rysownik = new Rysownik();
- Trojkat TrojkatOB = new Trojkat(10, 10);
- Kwadrat KwadratOB = new Kwadrat(10);
- Prostokat ProstokatOB = new Prostokat(10,5);
- rysownik.Rysuj(ProstokatOB);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement