Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace TicTacToe_Tura_Adrian
  12. {
  13. public partial class Form1 : Form
  14. {
  15.  
  16. bool x = true, f = false;
  17.  
  18. int c1 = 0, c2 = 0,c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0,n=0;
  19.  
  20.  
  21. public Form1()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. private void Form1_Load(object sender, EventArgs e)
  27. {
  28. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  29. }
  30.  
  31. void check_end()
  32. {
  33. if (n == 9)
  34. {
  35. f = true;
  36. txt_win.Text = "Remiză";
  37. }
  38.  
  39. if(c1==c2 && c2==c3 && c1!=0)
  40. {
  41. f = true;
  42. if (c1 == 1)
  43. txt_win.Text = "X a câștigat";
  44. else
  45. txt_win.Text = "0 a câștigat";
  46. }
  47.  
  48. if (c4 == c5 && c5 == c6 && c5 != 0)
  49. {
  50. f = true;
  51. if (c1 == 1)
  52. txt_win.Text = "X a câștigat";
  53. else
  54. txt_win.Text = "0 a câștigat";
  55. }
  56.  
  57. if(c7==c8 && c8==c9 && c7!=0)
  58. {
  59. f = true;
  60. if (c1 == 1)
  61. txt_win.Text = "X a câștigat";
  62. else
  63. txt_win.Text = "0 a câștigat";
  64. }
  65.  
  66. if(c1==c4 && c4==c7 && c1!=0)
  67. {
  68. f = true;
  69. if (c1 == 1)
  70. txt_win.Text = "X a câștigat";
  71. else
  72. txt_win.Text = "0 a câștigat";
  73. }
  74.  
  75. if(c2==c5 && c5==c8 && c2!=0)
  76. {
  77. f = true;
  78. if (c2 == 1)
  79. txt_win.Text = "X a câștigat";
  80. else
  81. txt_win.Text = "0 a câștigat";
  82. }
  83.  
  84. if(c3==c6 && c6==c9 && c3!=0)
  85. {
  86. f = true;
  87. if (c3 == 1)
  88. txt_win.Text = "X a câștigat";
  89. else
  90. txt_win.Text = "0 a câștigat";
  91. }
  92.  
  93. if(c1==c5 && c5==c9 && c1!=0)
  94. {
  95. f = true;
  96. if (c1 == 1)
  97. txt_win.Text = "X a câștigat";
  98. else
  99. txt_win.Text = "0 a câștigat";
  100. }
  101.  
  102. if(c3==c5 && c5==c7 && c3!=0)
  103. {
  104. f = true;
  105. if (c3 == 1)
  106. txt_win.Text = "X a câștigat";
  107. else
  108. txt_win.Text = "0 a câștigat";
  109. }
  110. }
  111.  
  112. private void b1_Click(object sender, EventArgs e)
  113. {
  114. if(c1==0 && f==false)
  115. {
  116. n++;
  117. if (x == true)
  118. {
  119. c1 = 1;
  120. x = false;
  121. b1.Text = "X";
  122. txt_mut.Text = "0";
  123.  
  124. }
  125. else
  126. {
  127. c1 = -1;
  128. x = true;
  129. b1.Text = "0";
  130. txt_mut.Text = "X";
  131. }
  132. }
  133. check_end();
  134. }
  135.  
  136. private void b2_Click(object sender, EventArgs e)
  137. {
  138. if (c2 == 0 && f == false)
  139. {
  140. n++;
  141. if (x == true)
  142. {
  143. c2 = 1;
  144. x = false;
  145. b2.Text = "X";
  146. txt_mut.Text = "0";
  147. }
  148. else
  149. {
  150. c2 = -1;
  151. x = true;
  152. b2.Text = "0";
  153. txt_mut.Text = "X";
  154. }
  155. }
  156. check_end();
  157. }
  158.  
  159. private void b3_Click(object sender, EventArgs e)
  160. {
  161. if (c3 == 0 && f == false)
  162. {
  163. n++;
  164. if (x == true)
  165. {
  166. c3 = 1;
  167. x = false;
  168. b3.Text = "X";
  169. txt_mut.Text = "0";
  170. }
  171. else
  172. {
  173. c3 = -1;
  174. x = true;
  175. b3.Text = "0";
  176. txt_mut.Text = "X";
  177. }
  178. }
  179. check_end();
  180. }
  181.  
  182. private void b4_Click(object sender, EventArgs e)
  183. {
  184. if (c4 == 0 && f == false)
  185. {
  186. n++;
  187. if (x == true)
  188. {
  189. c4 = 1;
  190. x = false;
  191. b4.Text = "X";
  192. txt_mut.Text = "0";
  193. }
  194. else
  195. {
  196. c4 = -1;
  197. x = true;
  198. b4.Text = "0";
  199. txt_mut.Text = "X";
  200. }
  201. }
  202. check_end();
  203. }
  204.  
  205. private void b5_Click(object sender, EventArgs e)
  206. {
  207. if (c5 == 0 && f == false)
  208. {
  209. n++;
  210. if (x == true)
  211. {
  212. c5 = 1;
  213. x = false;
  214. b5.Text = "X";
  215. txt_mut.Text = "0";
  216. }
  217. else
  218. {
  219. c5 = -1;
  220. x = true;
  221. b5.Text = "0";
  222. txt_mut.Text = "X";
  223. }
  224. }
  225. check_end();
  226. }
  227.  
  228. private void b6_Click(object sender, EventArgs e)
  229. {
  230. if (c6 == 0 && f == false)
  231. {
  232. n++;
  233. if (x == true)
  234. {
  235. c6 = 1;
  236. x = false;
  237. b6.Text = "X";
  238. txt_mut.Text = "0";
  239. }
  240. else
  241. {
  242. c6 = -1;
  243. x = true;
  244. b6.Text = "0";
  245. txt_mut.Text = "X";
  246. }
  247. }
  248. check_end();
  249. }
  250.  
  251. private void b7_Click(object sender, EventArgs e)
  252. {
  253. if (c7 == 0 && f == false)
  254. {
  255. n++;
  256. if (x == true)
  257. {
  258. c7 = 1;
  259. x = false;
  260. b7.Text = "X";
  261. txt_mut.Text = "0";
  262. }
  263. else
  264. {
  265. c7 = -1;
  266. x = true;
  267. b7.Text = "0";
  268. txt_mut.Text = "X";
  269. }
  270. }
  271. check_end();
  272. }
  273.  
  274. private void b8_Click(object sender, EventArgs e)
  275. {
  276. if (c8 == 0 && f == false)
  277. {
  278. n++;
  279. if (x == true)
  280. {
  281. c8 = 1;
  282. x = false;
  283. b8.Text = "X";
  284. txt_mut.Text = "0";
  285. }
  286. else
  287. {
  288. c8 = -1;
  289. x = true;
  290. b8.Text = "0";
  291. txt_mut.Text = "X";
  292. }
  293. }
  294. check_end();
  295. }
  296.  
  297. private void b9_Click(object sender, EventArgs e)
  298. {
  299. if (c9 == 0 && f == false)
  300. {
  301. n++;
  302. if (x == true)
  303. {
  304. c9 = 1;
  305. x = false;
  306. txt_mut.Text = "0";
  307. b9.Text = "X";
  308. }
  309. else
  310. {
  311. c9 = -1;
  312. x = true;
  313. b9.Text = "0";
  314. txt_mut.Text = "X";
  315. }
  316. }
  317. check_end();
  318. }
  319.  
  320. private void btn_exit_Click(object sender, EventArgs e)
  321. {
  322. Application.Exit();
  323. }
  324.  
  325. private void btn_reset_Click(object sender, EventArgs e)
  326. {
  327. c1 = c2 = c3 = c4 = c5 = c6 = c7 = c8 = c9 = n = 0;
  328. f = false;
  329. b1.Text = "";
  330. b2.Text = "";
  331. b3.Text = "";
  332. b4.Text = "";
  333. b5.Text = "";
  334. b6.Text = "";
  335. b7.Text = "";
  336. b8.Text = "";
  337. b9.Text = "";
  338. txt_win.Text = "";
  339. }
  340.  
  341. }
  342. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement