Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace zad_6._1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Witaj w moim programie");
  14.  
  15. Obraz kolekcja = new Obraz();
  16.  
  17.  
  18.  
  19. while (true)
  20. {
  21. Console.WriteLine("Co chcesz zrobic?");
  22.  
  23. Console.WriteLine("1.Stworzyc trojkat.");
  24. Console.WriteLine("2.Stworzyc czworokąt.");
  25. Console.WriteLine("3.Dodać trójkąt do kolekcji.");
  26. Console.WriteLine("4.Dodać kwadrat do kolekcji.");
  27.  
  28. int choise = int.Parse(Console.ReadLine());
  29.  
  30.  
  31. if (choise == 1)
  32. {
  33.  
  34. Console.WriteLine("Podaj wspolrzedne punktu");
  35. int Wspx = int.Parse(Console.ReadLine());
  36. int Wspy = int.Parse(Console.ReadLine());
  37.  
  38. Punkt dot1 = new Punkt(Wspx, Wspy);
  39.  
  40. Console.WriteLine("Podaj wspolrzedne punktu");
  41. Wspx = int.Parse(Console.ReadLine());
  42. Wspy = int.Parse(Console.ReadLine());
  43. Punkt dot2 = new Punkt(Wspx, Wspy);
  44.  
  45. Console.WriteLine("Podaj wspolrzedne punktu");
  46. Wspx = int.Parse(Console.ReadLine());
  47. Wspy = int.Parse(Console.ReadLine());
  48. Punkt dot3 = new Punkt(Wspx, Wspy);
  49.  
  50. if (dot1.X == dot2.X && dot1.Y == dot2.Y || dot1.X == dot3.X && dot1.Y == dot3.Y || dot2.X == dot3.X && dot2.Y == dot3.Y)
  51. {
  52. Console.WriteLine("Nie może być 2 tych samych punktów.");
  53. break;
  54.  
  55. }
  56.  
  57.  
  58. Linia line1 = new Linia(dot1, dot2);
  59. Linia line2 = new Linia(dot2, dot3);
  60. Linia line3 = new Linia(dot1, dot3);
  61.  
  62. if (line1.Dlugosc(dot1, dot2) >= line2.Dlugosc(dot2, dot3) + line3.Dlugosc(dot1, dot3) || line2.Dlugosc(dot2, dot3) >= line1.Dlugosc(dot1, dot2) + line3.Dlugosc(dot1, dot3) || line3.Dlugosc(dot1, dot3) >= line1.Dlugosc(dot1, dot2) + line2.Dlugosc(dot2, dot3))
  63. {
  64. Console.WriteLine("Nieodpowiednie długości boków.");
  65. break;
  66. }
  67.  
  68. Trojkat triangle = new Trojkat(line1, line2, line3);
  69.  
  70. Console.WriteLine("Czy dodac trojkat do kolekcji?");
  71. string wybor = Console.ReadLine();
  72.  
  73. if (wybor == "tak")
  74. {
  75. kolekcja.DodajTrojkat(triangle);
  76. }
  77. }
  78. else if (choise == 2)
  79. {
  80.  
  81. Console.WriteLine("Podaj wspolrzedne punktu");
  82. int Wspx = int.Parse(Console.ReadLine());
  83. int Wspy = int.Parse(Console.ReadLine());
  84.  
  85. Punkt dot1 = new Punkt(Wspx, Wspy);
  86.  
  87. Console.WriteLine("Podaj wspolrzedne punktu");
  88. Wspx = int.Parse(Console.ReadLine());
  89. Wspy = int.Parse(Console.ReadLine());
  90.  
  91. Punkt dot2 = new Punkt(Wspx, Wspy);
  92.  
  93. Console.WriteLine("Podaj wspolrzedne punktu");
  94. Wspx = int.Parse(Console.ReadLine());
  95. Wspy = int.Parse(Console.ReadLine());
  96.  
  97. Punkt dot3 = new Punkt(Wspx, Wspy);
  98.  
  99. Console.WriteLine("Podaj wspolrzedne punktu");
  100. Wspx = int.Parse(Console.ReadLine());
  101. Wspy = int.Parse(Console.ReadLine());
  102.  
  103. Punkt dot4 = new Punkt(Wspx, Wspy);
  104.  
  105. if (dot1.X == dot2.X && dot1.Y == dot2.Y || dot1.X == dot3.X && dot1.Y == dot3.Y || dot2.X == dot3.X && dot2.Y == dot3.Y || dot1.X == dot4.X && dot1.Y == dot4.Y || dot2.X == dot4.X && dot2.Y == dot4.Y || dot3.X == dot4.X && dot3.Y == dot4.Y)
  106. {
  107. Console.WriteLine("Nie może być 2 tych samych punktów.");
  108. break;
  109.  
  110. }
  111.  
  112. Linia line1 = new Linia(dot1, dot2);
  113. Linia line2 = new Linia(dot1, dot4);
  114. Linia line3 = new Linia(dot2, dot3);
  115. Linia line4 = new Linia(dot3, dot4);
  116.  
  117.  
  118.  
  119. Kwadrat square = new Kwadrat(line1, line2, line3, line4);
  120.  
  121.  
  122. Console.WriteLine(line1.toString());
  123.  
  124. Console.WriteLine("Czy dodac kwadrat do kolekcji?");
  125. string wybor1 = Console.ReadLine();
  126.  
  127. if (wybor1 == "tak")
  128. {
  129. kolekcja.DodajKwadrat(square);
  130. }
  131.  
  132. Console.WriteLine("O ile chcesz przesunac kwadrat?");
  133. int moveX = int.Parse(Console.ReadLine());
  134. int moveY = int.Parse(Console.ReadLine());
  135.  
  136. square.Przesun(moveX, moveY);
  137.  
  138.  
  139.  
  140. }
  141.  
  142.  
  143. }
  144.  
  145.  
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement