Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 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 Rysowanie
  8. {
  9. class Kwadrat
  10. {
  11. private int wysokosc = 0, szerokosc = 0;
  12. public string znak;
  13. public Kwadrat()
  14. {
  15. Console.ForegroundColor = ConsoleColor.Red;
  16. znak = "x";
  17. }
  18.  
  19. public void rysuj()
  20. {
  21. Console.WriteLine("Podaj wysokosc");
  22. wysokosc = Convert.ToInt32(Console.ReadLine());
  23. Console.WriteLine("Podaj szerokośc");
  24. szerokosc = Convert.ToInt32(Console.ReadLine());
  25. for (int a = 0; a < wysokosc; a++)
  26. {
  27.  
  28. for (int b=1; b < szerokosc; b++)
  29. {
  30. Console.Write(znak);
  31. }
  32. Console.WriteLine(znak);
  33. }
  34.  
  35.  
  36. Console.ReadKey();
  37.  
  38. }
  39. }
  40.  
  41. class Trojkat
  42. {
  43.  
  44. static Trojkat()
  45. {
  46. Console.ForegroundColor = ConsoleColor.Yellow;
  47.  
  48. }
  49. public static void rysuj()
  50. {
  51. int wysokosc = 0;
  52. Console.WriteLine("Podaj wysokość");
  53. wysokosc = Convert.ToInt32(Console.ReadLine());
  54. for (int wiersze = 1; wiersze <= wysokosc; wiersze++)
  55. {
  56. for (int a = wysokosc; a > wiersze; a--)
  57. {
  58. Console.Write(" ");
  59. }
  60.  
  61. for (int gwiazdki = 0; gwiazdki < wiersze; gwiazdki++)
  62. {
  63. Console.Write("*");
  64. }
  65. for (int gwiazdki = 1; gwiazdki < wiersze; gwiazdki++)
  66. {
  67. Console.Write("*");
  68. }
  69. Console.WriteLine("");
  70. }
  71. Console.ReadKey();
  72. }
  73. }
  74. class Kolo
  75. {
  76. public string znak = "";
  77. private int wysokosc = 0;
  78. public Kolo(Kwadrat kolo)
  79. {
  80. Console.ForegroundColor = ConsoleColor.Green;
  81.  
  82. }
  83.  
  84. public Kolo(int wysokosc_kola)
  85. {
  86.  
  87. wysokosc = wysokosc_kola;
  88. }
  89.  
  90.  
  91. public void rysuj()
  92. {
  93. Console.WriteLine("Podaj średnice");
  94. wysokosc = Convert.ToInt32(Console.ReadLine());
  95. for (int wiersze = 1; wiersze <= wysokosc; wiersze++)
  96. {
  97. for (int a = wysokosc; a > wiersze; a--)
  98. {
  99. Console.Write(" ");
  100. }
  101.  
  102. for (int gwiazdki = 0; gwiazdki < wiersze; gwiazdki++)
  103. {
  104. Console.Write("X");
  105. }
  106. for (int gwiazdki = 1; gwiazdki < wiersze; gwiazdki++)
  107. {
  108. Console.Write("X");
  109. }
  110. Console.WriteLine("");
  111.  
  112. }
  113. for (int wiersze = 1; wiersze <= wysokosc-1; wiersze++)
  114. {
  115. for (int a = 1; a <= wiersze; a++)
  116. {
  117. Console.Write(" ");
  118. }
  119.  
  120. for (int gwiazdki = wysokosc; gwiazdki >= wiersze+1; gwiazdki--)
  121. {
  122. Console.Write("X");
  123. }
  124. for (int gwiazdki = wysokosc ; gwiazdki >= wiersze+2; gwiazdki--)
  125. {
  126. Console.Write("X");
  127. }
  128. Console.WriteLine("");
  129.  
  130. }
  131. Console.ReadKey();
  132.  
  133.  
  134.  
  135. }
  136. }
  137. class Program
  138. {
  139. static void Main(string[] args)
  140. {
  141.  
  142. Console.WriteLine("Witam w programie do rysowania\n" +
  143. "1. Rysowanie Kwadratu\n" +
  144. "2. Rysowanie Trojkata\n" +
  145. "3. Rysowanie Koła\n");
  146. int funkcja;
  147. funkcja = Convert.ToInt32(Console.ReadLine());
  148. switch(funkcja)
  149. {
  150. case 1:
  151. {
  152. Console.Clear();
  153. Console.WriteLine("Rysowanie Kwadratu");
  154. Kwadrat kwadrat1 = new Kwadrat();
  155. kwadrat1.rysuj();
  156. break;
  157. }
  158. case 2:
  159. {
  160. Console.Clear();
  161. Console.WriteLine("Rysowanie Trójkąta");
  162. //Trojkat trojkat1 = new Trojkat();
  163. Trojkat.rysuj();
  164. break;
  165. }
  166. case 3:
  167. {
  168. Console.Clear();
  169. Console.WriteLine("Rysoawnie Koła");
  170. Kolo kolo1 = new Kolo();
  171. kolo1.rysuj();
  172. break;
  173. }
  174.  
  175.  
  176.  
  177.  
  178. default:
  179. {
  180. Console.Clear();
  181. Console.WriteLine("ZŁE DANE! PROGRAM ZOSTANIE ZAMKNIĘTY!");
  182. break;
  183. }
  184.  
  185.  
  186. }
  187. }
  188. }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement