If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h
ARE YOU SERIOUS DUDE!?? HOWWW I LITERALLY GOT MY ASSIGNMENT OF MAKING TIC TAC TOE YESTERDAY AND I NEEDED HELP AND GUESSS WHAT.... YOU JUST MADE A WHOLE VIDEO ABOUT ITTTTT!!! THANK YOUUUUU
notice how he is making mistakes in middle and correcting them ,makes me realize that making little mistakes while programming is so common and normal ... it's as if he is talking to us while programming unlike some programmers who r like - " so we r gonna do this and that and tadda" , really makes me feel kinda dumb bcoz when I try to program I really do lots of small mistakes like Alex ... really very nice video .. enjoyed it ..
Don't worry about making mistakes. If people didn't do them, what would be the usage of Stackoverflow then? There is a challange for doing 100 lines of code without any mistake, pretty hard tho.
I've got to say when I started learning Java certain things I found really tough but your channel help strengthen the areas I was weak and also gave me more passion to learn how to code. Thanks for all the lessons.
Hi just pointing out a small bug: If you place a winning piece as the last move - it will still register as a Tie, since you put the last "else if" in the for loop on line 118. Put this check as a separate if statement outside the for loop and it solves it. Great video thanks for sharing
Can you please explain why this bug comes up. Because before checkWinner() we do the putPiece() function which should automatically add the last position in our list of player positions. After that, the first if condition which prints "congrats" should be satisfied. Please explain where I am going wrong with this logic. Edit : I got why the bug appears. In the if condition, we go through all the possible winning arrangements inside the winning list. Therefore, if the last position is not part of the top row, then the tie condition will be satisfied before the win condition and "Tie" will be returned, breaking out of the checkWinner() method.
Thx man I'm a newbie to the game creation part of java I just do like easy stuff for like to find the hypotenuse length or like trigonometry. This thing really triggered me when the winning piece was the last, but thx for ur fix, I can now proudly say my first successful game created was TiC tAc ToE
Kinda followed until about halfway through and then did this on my own. And then I modified it with the lists you added. Really cool tutorial, very easy to follow and understand!
Great explanation!! 🙌 Don't get disheartened if it takes more than 30 mins to learn . I'm a beginner. TBH it took me 6 hours and I'm proud of myself because this is my first mini project /game and i could totally understand and do it on my own .😇
and after four hours my jdk was just a peice of shit cuz it showed 128 errors then i. decreased them to 0 and still they showed there's a syntax error and. when we check there were no red lines like it showed there was an error but at the same time showed there were none
I liked the way you took care of overlapping moves. I was trying to code on my own whenever I could and then check how you did it. The way I did it worked too, but made the code quite lengthy and a bit repetitive. It was a good experience to learn how to code more efficiently!
Who knew that the game tic tac tow would be this hard lol. I just started coding juts like a month ago and beggining to undertsand arrays. Ur videos help out a ton! This video happened to be in my recommended so I clicked it. Amazing video!!! Keep up the good work! 👍
Awesome tutorial! I went through all of it with you. Please post more! From a teaching standpoint, I suggest placing stops in your videos. Good spots would be after you describe what the next step is. (Like: Prior to making a method, give the name of the method and pause for followers to develop their own pseudo code.) This involves users, allows you to get ideas from users, and makes this more of a teaching session. Best part is you can add these breaks in post.
Nice one I’ll do it when I complete my java course and know all these statements. We have finished array and next we’ll learn classes , set, and get ... Thanks bro I like your way to teach ! I hope you can be something special in the future because you always inspiring me !
hello, i tried this code but there's an error in && playerPositions.size()+ cpuPositions.size() == 9) it says "illegal start of expression" can you help me plsss
hey, your video is excellent. It's good for people to see the true process of a programmer making code, trial and error. The code I would have done differently without so much repetitive code and doing better practices, but it turned out very well in the end.
@@nanonssmile bro don't give up lol, just stick with it, I'll tell you something i did, i had started playing this game called kerbal space program then i found out theres a programing language just for the game exclusively and once i downloaded it, (its called kos ksp) i learned how to fly my rockets autonomously and then thats when it hit me lol, programming has become so much easier to understand now that I've learned that kerbal space programing language and could see the result of my code in real time with the rocket, once i achieved orbit with no help and just me coding out my own code after learning kos, I've been back into programming ever since and everything looks way different than it did before, because i understand now whats going on, so don't give up bro, find alternative ways to learn coding just like i did and i promise you, you will be thankful you did, btw java is so easy, its pretty much the easiest language to learn and you'll see why once you learn how to code, you'll see how java is so much more easier than people make it out to be, trust me easiest language to learn by far and i highly recommend you stick with java
Hey one tip, when using switches, use case -> instead of :, you don't need breaks, you don't need returns and the Java Compiler compiles it much faster than the other variant. Only works in Jdk 13 though Edit: when switching between players, you could do it with a Boolean instead of a string and a equals method. I know this is just a simple tutorial and honestly it was great. I'm just here trying to help and improve the quality :)
I used to suck in java now you are the almighty overlord in teaching lol Please like this comment i did your login and simple GUI tutorial video. My parents are proud
Started learning to code Java 4 days ago still confused af but decided to go along with this and see from what i've learnt and damn its starting to make sense now! Big ups much love!
As of Java 13, you can use much better looking and shorter, "enhanced" switch statements: switch (position) { case 1 -> board[0][0] = symbol; case 2 -> board[0][2] = symbol; case 3 -> board[0][4] = symbol; case 4 -> board[2][0] = symbol; case 5 -> board[2][2] = symbol; case 6 -> board[2][4] = symbol; case 7 -> board[4][0] = symbol; case 8 -> board[4][2] = symbol; case 9 -> board[4][4] = symbol; default -> {} } Mind the missing semi-colon after "default -> {}", it's mandatory.
line 26 of your code should be playerPos not playerPositions. I was confused for a while because I was able to take the CPU positions in game. This was good for troubleshooting though!
You should make a C++ tutorial. I like your teaching style compared to some other channels where they go over important concepts too quickly and speak too fast sometimes.
Hope you make long videos like thats more often, its am still learning java and this type of videos help me to recover all what a learn and learn more logic int these statements, also the things i didn't learn yet is becoming more familiar to me and doesn't have an issue with it in class THANK YOU SO MUCH I realy im thinking to do videos like in my own language after i learn java because alot of student that doesn't understan english very will struggle to find a learning videos
Shouldn't the second while loop in main be like this? Just incase user selects a position where the cpu has already gone. while(playerPositions.contains(playerPos) || cpuPositions.contains(playerPos)){ System.out.println("Position taken! Enter a correct Position"); playerPos= scan.nextInt(); }
Yo your video helped alot some how i learned making a card game by my self (took me a couple of hours but it turned ok ) just by watching how coding works on your video's keep up these video's!
I found the user was able to input on top of what CPU had already entered. I don't know where I made the mistake because I have the code the same as yours. The CPU is not printing on top of the user but the user can print on top of the CPU. If the user tries to enter on top of the user's own input, that's when the Choose another position error message pops up. I don't know if this is a bug or problem with my code.
It is not your mistake. Alex has skipped that. So, just copy and paste this code in the while loop of the user😃😃. while(playerPositions.contains(playerPos) || cpuPositions.contains(playerPos)){ System.out.println("Position taken! Enter a correct Position"); playerPos= scan.nextInt(); }
I used almost none of this but this inspired me to use what I needed too💀💀💀 let’s just say I used way to me if loops😭 (I really don’t mind because copy and paste is a king!!!)
This is an incredible video, thank you for all the effort you put in.I know I cant ask you for more, but it would be great if you teaches us a little bit more about AI and the stuff you mentioned in the video.
Heads Up: The loop for checking a win has an error. It will only check one win scenario after 9 moves. Since there have been 9 moves, the third part triggers and shows a tie, regardless of the outcome. You need to move the tie check out of the loop and then it can run after all win scenarios are checked. (Thanks Alex for helping me get started with Java.)
Hey this is awesome man. Games and gui programs usually engage people and let them learn with exciement. My question is, with your experience, do you study and do the prrograms before making a video or do you just do it as you record? It seems very natural for you.
Hello Alex on line 26 not sure if you corrected it afterwards but on that line it's supposed to be "playerPos" when you used "playerPosition". If it's not switched, it still let's player put X's where there are some O's. Amazing step by step though. I learned a lot from it. Also you probably won't see my message but i appreciate your videos.
Alex you missed one scenario where, if all the positions are filled and only last position is blank. Then user has to put X in last position and actually by putting X in last position he will win. But as we are having a condition if board is full then it will give us tie message, so its showing a tie. But actually Player wins that case
is there really not a better way to check all the cases? so much code to do that... i have a similar program and did the same thing but its stressing me out because its so many “if” statements and im worried to put it on my resume in case its bad coding
So I'm following along with this, but for List topRow and all the others, it gives me an error saying "Type mismatch: cannot convert from List to List" did I do something wrong here?
Great Videos, I love your channel. It would be great if you could make the TicTacToe game using graphics, awt, swing. It would be a great lesson on extending and using canvas. Thanks again.