How to Create A Tic Tac Toe App In C# | Visual Studio 2019 | Part 1

  Рет қаралды 10,751

Shaun Halverson

Shaun Halverson

Күн бұрын

Пікірлер: 48
@zero-9435
@zero-9435 2 жыл бұрын
First of all I have to admit that this tutorial is really good, but there is one problem. If you win with the last turn, it just says „Thats a draw“ .I guess you have to add an else{CheckDraw()}
@ShaunHalverson
@ShaunHalverson 2 жыл бұрын
Thank you and thank you for the tip as well, it’s hard to handle all cases but I will pin a comment for future viewers!
@cljalamana1190
@cljalamana1190 4 жыл бұрын
This channel is by far the best way to learn
@cljalamana1190
@cljalamana1190 4 жыл бұрын
But i do recommend when you write code you say the code and zoom in so that we dont need to set quality to 720p and load longer and put our eyes on the screen to see the code
@ShaunHalverson
@ShaunHalverson 4 жыл бұрын
I'm glad you think so! This comment means alot, thank you very much :)
@ShaunHalverson
@ShaunHalverson 4 жыл бұрын
@@cljalamana1190 I will keep that in mind! Was the level of Zoom that i had on this video okay ? Or should I zoom in even more than i already did ?
@cljalamana1190
@cljalamana1190 4 жыл бұрын
@@ShaunHalverson i reccomend zooming in much more
@Havii
@Havii 4 жыл бұрын
@@ShaunHalverson For VStudio this is actually pretty okay. For web videos, zoom in would be very useful since it's pretty small and it hurts my eyes if I have to focus hard 😅 But like he said, definitely the best channel to learn. I love your videos a lot.
@thomasprinsen1247
@thomasprinsen1247 3 жыл бұрын
Thank you for these awesome videos!
@ShaunHalverson
@ShaunHalverson 2 жыл бұрын
Glad you like them!
@balkanxd5900
@balkanxd5900 3 жыл бұрын
You are the best chanell for learn.
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
Thank you :)
@Awesomebaws33
@Awesomebaws33 3 жыл бұрын
Your case 6 and 7 on CheckForWinner function are a bit wrong. For example the index for case 6 should be" combination = gameboard[1], [4] and [7]" for the vertical winning line. The first index gameBoard[2] is the only incorrect number in your combination code for case 6 :). Error came from writing 1,2,3 at the top line boxes instead of 0,1,2 @16:00. Other than that an excellent tutorial video!
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
Thank you for the feedback!
@itz_jiryn8162
@itz_jiryn8162 3 жыл бұрын
Wery helpful, thack you!
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
Glad to hear it!
@sam_the_yardman
@sam_the_yardman 2 жыл бұрын
this video is good, no cap
@mstrnabeel2605
@mstrnabeel2605 3 жыл бұрын
Nice dude, very helpfull. But i have a query. If we double click on a button that button will change from X to O or O to X.. that needs to be validate. How will we do that.
@mstrnabeel2605
@mstrnabeel2605 3 жыл бұрын
Also if we have more than one combinations to win then it also shows us game is drawn.
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
Hmmm. Thank you for reporting these bugs! I will need to glance at the code and get back to you with how to fix it.
@mstrnabeel2605
@mstrnabeel2605 3 жыл бұрын
Thanks dude ! 👏
@ShaunHalverson
@ShaunHalverson 2 жыл бұрын
So I just took a look, maybe try moving checkdraw() after the winning if/else statements? That way the winner will be checked first and if there isn't one, it will then check for a draw. Let me know how that works.
@mstrnabeel2605
@mstrnabeel2605 2 жыл бұрын
Ok I'll check..
@zero-9435
@zero-9435 2 жыл бұрын
Hi there is the problem that if you win with the last turn, it just keeps saying „Thats a draw“ and it doesnt work with else checkfordraw. Do you maybe know how to fix this issue?Thy
@purd691
@purd691 3 жыл бұрын
When I write “button1.Text = gameBoard[0]; it says “CS0103 The name ‘button1’ dose not exist in the current context” may you please help
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
That kind of looks like your button1 might be in a spot that isn’t accessible to everything. Can I see your code somehow?
@agentbomz1222
@agentbomz1222 3 жыл бұрын
Can you pls make a vid so u can play with an ai? I have mid term on this and I have no idea how to do it
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
I would love to, but I unfortunately don't have any experience with AI yet. I would like to get into that for future videos tho. Just super complicated stuff!
@agentbomz1222
@agentbomz1222 3 жыл бұрын
It's ok :)
@EeveeShadowBacon
@EeveeShadowBacon 2 жыл бұрын
My i's for the (i=0,i
@ShaunHalverson
@ShaunHalverson 2 жыл бұрын
You need to say int i=0 in the first part
@ShaunHalverson
@ShaunHalverson 2 жыл бұрын
Also make sure you have semicolons in between each one for(int i=0; i < 8; i++)
@EeveeShadowBacon
@EeveeShadowBacon 2 жыл бұрын
@@ShaunHalverson got it, thanks
@mackl0533
@mackl0533 3 жыл бұрын
For my if(combination.Equals(“000”)) it keeps saying system.NullreferenceException : object reference not set to an instance of an object Pls help
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
I think it’s complaining that your combination variable is not being set somewhere and by the time the if fires, there’s no .equals property to access because the object is null
@mackl0533
@mackl0533 3 жыл бұрын
@@ShaunHalverson so how would I go about fixing it
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
@@mackl0533 check your combination variable and compare it with the video to see if you missed anything. If you can't find anything, you can add me on discord @ Shaun#5626 or paste your code here and I can take a look
@fizamubeen7701
@fizamubeen7701 2 жыл бұрын
Hey sir can you please give this game source code because I have some error
@ShaunHalverson
@ShaunHalverson 2 жыл бұрын
I actually got a new computer and don’t have the source code anymore lol, but what is your error? I can try to help
@FunTimesWithGray
@FunTimesWithGray 3 жыл бұрын
Hello i have a problem which is only the button 1 shows the letter X and O and everytime I click it shows that there is a winner even tho i only click once Here is my code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TicTacToe { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string[] gameboard = new string[9]; int currentturn = 0; public string returnSymbol(int turn) { if (turn % 2 == 0) { return "0"; } else { return "X"; } } public void checkForWinner() { for (int i = 0; i < 8; i++) { string combination = ""; switch (i) { case 0: combination = gameboard[0] + gameboard[4] + gameboard[8]; break; case 1: combination = gameboard[2] + gameboard[4] + gameboard[6]; break; case 2: combination = gameboard[0] + gameboard[1] + gameboard[2]; break; case 3: combination = gameboard[3] + gameboard[4] + gameboard[5]; break; case 4: combination = gameboard[6] + gameboard[7] + gameboard[8]; break; case 5: combination = gameboard[0] + gameboard[3] + gameboard[6]; break; case 6: combination = gameboard[1] + gameboard[4] + gameboard[7]; break; case 7: combination = gameboard[2] + gameboard[5] + gameboard[8]; break; } if (combination.Equals("")) { MessageBox.Show("O has won the game", "we have a winner!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("X has won the game", "we have a winner!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } private void button1_Click(object sender, EventArgs e) { currentturn++; gameboard[0] = returnSymbol(currentturn); button1.Text = gameboard[0]; checkForWinner(); } private void button2_Click(object sender, EventArgs e) { currentturn++; gameboard[1] = returnSymbol(currentturn); button1.Text = gameboard[1]; checkForWinner(); } private void button3_Click(object sender, EventArgs e) { currentturn++; gameboard[2] = returnSymbol(currentturn); button1.Text = gameboard[2]; checkForWinner(); } private void button4_Click(object sender, EventArgs e) { currentturn++; gameboard[3] = returnSymbol(currentturn); button1.Text = gameboard[3]; checkForWinner(); } private void button5_Click(object sender, EventArgs e) { currentturn++; gameboard[4] = returnSymbol(currentturn); button1.Text = gameboard[4]; checkForWinner(); } private void button6_Click(object sender, EventArgs e) { currentturn++; gameboard[5] = returnSymbol(currentturn); button1.Text = gameboard[5]; checkForWinner(); } private void button7_Click(object sender, EventArgs e) { currentturn++; gameboard[6] = returnSymbol(currentturn); button1.Text = gameboard[6]; checkForWinner(); } private void button8_Click(object sender, EventArgs e) { currentturn++; gameboard[7] = returnSymbol(currentturn); button1.Text = gameboard[7]; checkForWinner(); } private void button9_Click(object sender, EventArgs e) { currentturn++; gameboard[8] = returnSymbol(currentturn); button1.Text = gameboard[8]; checkForWinner(); } } }
@balkanxd5900
@balkanxd5900 3 жыл бұрын
When I type combination = gameBoard[0] + gameBoard[4] = gameBoard[8]; and then say is error
@ShaunHalverson
@ShaunHalverson 3 жыл бұрын
Hi! So the issue with that example is that you can’t have 2 equal signs in one statement. Did you mean to type that?
@JusteYoki
@JusteYoki 3 жыл бұрын
gg
@AMOiLLi
@AMOiLLi Жыл бұрын
Hi there is the problem that if you win with the last turn, it just keeps saying „Thats a draw“ and it doesnt work with else checkfordraw. Do you maybe know how to fix this issue?
How to Create A Tic Tac Toe App In C# | Visual Studio 2019 | Part 2
23:09
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 3,9 МЛН
这是自救的好办法 #路飞#海贼王
00:43
路飞与唐舞桐
Рет қаралды 128 МЛН
Create A Calculator App in C# | Visual Studio 2020 | Part 1
13:30
Shaun Halverson
Рет қаралды 45 М.
Visual Studio Winform Tic Tac Toe Tutorial Example (C#)
32:34
Chris Merritt
Рет қаралды 568 М.
How to Create Advanced Tic Tac Toe Game in C#
32:39
DJ Oamen
Рет қаралды 27 М.
DHH discusses SQLite (and Stoicism)
54:00
Aaron Francis
Рет қаралды 98 М.
Why 4d geometry makes me sad
29:42
3Blue1Brown
Рет қаралды 735 М.
Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
41:35
GOTO Conferences
Рет қаралды 818 М.
How To Create A Password Generator App In C# | Visual Studio 2019
18:46