Tic Tac Toe Java Game - Build a Tic Tac Toe Game in 30 Minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024

ความคิดเห็น • 764

  • @alexlorenlee
    @alexlorenlee  ปีที่แล้ว +8

    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

    • @SwiperANASS
      @SwiperANASS 10 หลายเดือนก่อน

      drive.google.com/drive/folders/1PwkFRjycQ0H2duh0iOZ52W-GxTHcbmmO?usp=sharing

  • @angelsdemons8520
    @angelsdemons8520 4 ปีที่แล้ว +407

    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 ..

    • @coolfred9083
      @coolfred9083 4 ปีที่แล้ว +2

      Yeah I think small mistakes are very common

    • @Maks-wp2wj
      @Maks-wp2wj 4 ปีที่แล้ว +2

      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.

    • @cacoca79
      @cacoca79 3 ปีที่แล้ว

      hes not telling you we here to go to make the game

    • @ptcreborntm
      @ptcreborntm 3 ปีที่แล้ว +1

      th-cam.com/video/eeIbIJR0HqQ/w-d-xo.html

    • @alexbaltimore
      @alexbaltimore 3 ปีที่แล้ว

      Agile development best route! Make mistakes, debug, get feedback, and build a better application

  • @chrysilius0
    @chrysilius0 5 ปีที่แล้ว +1093

    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

    • @onlyios9077
      @onlyios9077 5 ปีที่แล้ว +8

      what year are you in?

    • @chrysilius0
      @chrysilius0 5 ปีที่แล้ว +32

      @@onlyios9077 2008
      Why?

    • @onlyios9077
      @onlyios9077 5 ปีที่แล้ว +6

      @@chrysilius0 I'm In CS and never got such an assignement

    • @chrysilius0
      @chrysilius0 5 ปีที่แล้ว +5

      @@onlyios9077 I'm actually doing java course

    • @usernameundefined123
      @usernameundefined123 5 ปีที่แล้ว +36

      He did it after I submitted mine 😭😭

  • @RajSingh-yj7zj
    @RajSingh-yj7zj 5 ปีที่แล้ว +361

    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.

    • @supptk
      @supptk 4 ปีที่แล้ว

      @Idk I just want to comment Riley And I left it at 69.😁

    • @RajSingh-yj7zj
      @RajSingh-yj7zj 4 ปีที่แล้ว

      Riley you have done the world a great service

  • @anlunjiang
    @anlunjiang 4 ปีที่แล้ว +274

    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

    • @peterszarvas94
      @peterszarvas94 4 ปีที่แล้ว +7

      Thanks, I was also thinking how to solve this bug, but you answered.

    • @praneetkarna8498
      @praneetkarna8498 4 ปีที่แล้ว +14

      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.

    • @Asdf-wm4ow
      @Asdf-wm4ow 4 ปีที่แล้ว +3

      @@praneetkarna8498 Thank you for the edit now I understand also

    • @lamellama7450
      @lamellama7450 4 ปีที่แล้ว +3

      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

    • @سميححمدان-س1ق
      @سميححمدان-س1ق 3 ปีที่แล้ว

      Thanks a lot.. 😊

  • @Jechew
    @Jechew 4 ปีที่แล้ว +89

    5:03 Cool, cool, cool. Save and run. And it still works.
    I felt that

    • @BeiggoMC
      @BeiggoMC 4 ปีที่แล้ว +3

      Lol

  • @shatha-u6q
    @shatha-u6q 4 ปีที่แล้ว +224

    the fact that I spent 1HOUR in the first 6 minutes is absolutely mad

    • @Anila-te4fe
      @Anila-te4fe 3 ปีที่แล้ว +25

      Trust the process :)

    • @kevinthegamedev9049
      @kevinthegamedev9049 3 ปีที่แล้ว +9

      I had the same frustrating issue too. :(

    • @vivansheth1902
      @vivansheth1902 3 ปีที่แล้ว +1

      same bro

    • @tobber5582
      @tobber5582 3 ปีที่แล้ว +1

      3 hours

    • @vivansheth1902
      @vivansheth1902 3 ปีที่แล้ว +3

      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

  • @susmitapatro3082
    @susmitapatro3082 3 ปีที่แล้ว +33

    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 .😇

  • @BlazerBoy1337
    @BlazerBoy1337 8 หลายเดือนก่อน +2

    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!

  • @tabrezshaikh7705
    @tabrezshaikh7705 4 ปีที่แล้ว +38

    HANDS DOWN
    SIMPLEST TIC TAC TOE PROGRAM + EXPLANATION.
    good work bruhh

    • @christianjmyhre
      @christianjmyhre 3 ปีที่แล้ว

      I wish I could see this in c++ but this was great!

  • @catombomb3003
    @catombomb3003 ปีที่แล้ว +9

    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!

  • @mindofpaul9543
    @mindofpaul9543 2 ปีที่แล้ว +2

    That cut at 21:03 made me think there was some magical hotkey combination I was missing to fill in all that info lol. I had to watch back a few times to realize it was just the magic of editing.

  • @carlosmurcia9379
    @carlosmurcia9379 4 ปีที่แล้ว +9

    I love your teaching style! Really easy to understand and make seem less scary to code in Java!

  • @YTKP21
    @YTKP21 3 ปีที่แล้ว +4

    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! 👍

  • @day35ofdebuggingthesamelin56
    @day35ofdebuggingthesamelin56 5 ปีที่แล้ว +10

    I started to watch your java tutorial videos and now I have watched like 15 of them and ended up here. You are great at explaining things. Thanks!

  • @JaketheSnakeh64
    @JaketheSnakeh64 4 ปีที่แล้ว +28

    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.

  • @bl6622
    @bl6622 5 ปีที่แล้ว +28

    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 :)

    • @archangeltactics3802
      @archangeltactics3802 4 ปีที่แล้ว +1

      i use : all the time imma try and switch it one day but I doubt it

  • @prawnydagrate
    @prawnydagrate 4 ปีที่แล้ว +3

    I'm wanting to learn Java for Android app development, and your videos are kinda helpful for me. Thanks!

  • @JewelFornillas
    @JewelFornillas 4 ปีที่แล้ว +6

    Im learning java here and this is my first project :)

  • @westonpotgieter8131
    @westonpotgieter8131 5 ปีที่แล้ว +47

    More short games please.

  • @manuelmojicas
    @manuelmojicas 2 ปีที่แล้ว

    These were the best 30min Investment in my life. Thank you for the commitment my friend.

  • @didghkwls
    @didghkwls 4 ปีที่แล้ว +8

    This is awesome. I'm a very beginner of Java and I hope that I could make it like you do in the future. I know I have to practice over and over again! Thank you 😉

    • @asikurrahman4354
      @asikurrahman4354 4 ปีที่แล้ว +2

      You taking Computer science in college ? Its easy during the first few lessons lol and then it gets I harder and I get lost.

  • @swatishambhavi3649
    @swatishambhavi3649 4 ปีที่แล้ว +3

    Please make more such videos. You explain everything so nicely.

  • @biophilic23
    @biophilic23 3 ปีที่แล้ว +4

    i have no words to describe how grateful i'm after watching your java tutorials. YOU ARE AWESOME

  • @mb98765
    @mb98765 4 ปีที่แล้ว +3

    i LOVE how slow-paced these are. some of the best tutorials I've seen

  • @rampage14x13
    @rampage14x13 5 ปีที่แล้ว +3

    Im graduating next semester in cs and math and I still like watching all your videos even though Java is probably the language I know best lol

  • @hazedraisin2198
    @hazedraisin2198 2 ปีที่แล้ว

    There’s nothing more satisfying than thinking of the same solution to the same problem at the same time as Alex

  • @tehminakakar8753
    @tehminakakar8753 3 ปีที่แล้ว +2

    OMG This was the best tutorial I've ever seen over internet. I just love the way, he make things easy for beginner like me. Thank you so much.

  • @Conducttor
    @Conducttor ปีที่แล้ว +1

    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.

  • @WRYtube14
    @WRYtube14 4 หลายเดือนก่อน

    Please make more java tutorials ,like making gui for this game and making it real life app or sth .Please do more tutorials ,we love u ,you are a great teacher!!

  • @peterswrath
    @peterswrath 3 ปีที่แล้ว +4

    I honestly can't imagine watching anyone else for Java tutorials! Your videos helped me so much, and further made me want to develop games on my own.

  • @nithinputchakayala9032
    @nithinputchakayala9032 5 ปีที่แล้ว +6

    Dude thank you very much. Literally got the same project. Thank you very much!!!!

  • @spidy6120
    @spidy6120 3 ปีที่แล้ว +3

    After watching, oomgg i think i need to practise a lot to put all the func together without error.

  • @romitmohane4891
    @romitmohane4891 4 ปีที่แล้ว +66

    That helped me build tictactoe in PYTHON XD

    • @martingogaming1777
      @martingogaming1777 3 ปีที่แล้ว +2

      How to program tic tac toe in script languages LOL

    • @nanonssmile
      @nanonssmile 3 ปีที่แล้ว +1

      Can you share your python code? I'm really struggling...😰

    • @antwarior
      @antwarior 3 ปีที่แล้ว +1

      @@nanonssmile have you gotten everything under control?

    • @nanonssmile
      @nanonssmile 3 ปีที่แล้ว

      @@antwarior I really tried, many times... but then I gave up😅

    • @antwarior
      @antwarior 3 ปีที่แล้ว +1

      @@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

  • @MRodzor
    @MRodzor 4 ปีที่แล้ว

    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!

  • @abhinavkrothapalli3224
    @abhinavkrothapalli3224 5 ปีที่แล้ว +16

    Thanks a lot man! I appreciate this a lot, very helpful. :)

  • @nityaranjan6714
    @nityaranjan6714 3 ปีที่แล้ว +4

    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

  • @marcusallen2485
    @marcusallen2485 4 ปีที่แล้ว +1

    suggestion.... change the white places on the origional gameBoard to the corresponding numbers to know where you are playing

  • @dougie119
    @dougie119 4 ปีที่แล้ว +13

    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!

  • @gourangakhande8036
    @gourangakhande8036 2 ปีที่แล้ว

    great video showcasing how to code in stages while doing a big project.

  • @yuruji2189
    @yuruji2189 5 ปีที่แล้ว +22

    I needed this so much. Thanks!

  • @adrianguillermo629
    @adrianguillermo629 2 ปีที่แล้ว +1

    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.

  • @Meto31_
    @Meto31_ 3 ปีที่แล้ว

    Bro u did the most brutal hardcode TicTacToe for Java I have ever seen

  • @dannyluna3097
    @dannyluna3097 2 ปีที่แล้ว +1

    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!!!)

  • @__-cd1nd
    @__-cd1nd 5 ปีที่แล้ว +8

    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 !

    • @alexlorenlee
      @alexlorenlee  5 ปีที่แล้ว +3

      Thank you! Good luck in your classes!

    • @__-cd1nd
      @__-cd1nd 5 ปีที่แล้ว +2

      Alex Lee omggg he’s replying again !!! Literally! I’m on the cloud nine 😭💜
      Thanks , you too bro😻

    • @obidahasdia4095
      @obidahasdia4095 5 ปีที่แล้ว +3

      @@alexlorenlee me too thanks

    • @__-cd1nd
      @__-cd1nd 5 ปีที่แล้ว

      Obida Hasdia 🤩

    • @__-cd1nd
      @__-cd1nd 5 ปีที่แล้ว

      Alexander Zavadsky
      Really man ...🤦🏻‍♀️ Ah shit .. here we go again

  • @croczgamings2828
    @croczgamings2828 4 ปีที่แล้ว

    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

  • @ollievilair
    @ollievilair ปีที่แล้ว

    i did not expect you to slowly and menacingly pop up in the first few seconds lmaoo 😭 great video!!

  • @manishmadan5543
    @manishmadan5543 4 ปีที่แล้ว +1

    I have made this game earlier but you gave me better ideas to bring an update to my game and make it better.
    Thanks for the video Alex!

  • @torch4762
    @torch4762 5 ปีที่แล้ว +2

    @Alex Lee, nice video, thanks a lot for it. I learned massively, and I wish I had this 2 years

    • @zyhru
      @zyhru 3 ปีที่แล้ว

      How much have you learned?

    • @torch4762
      @torch4762 3 ปีที่แล้ว

      @@zyhruAlex helped me refresh and understand basic concepts up to OOP. As far as what I've learned since I posed a year ago, well I figured out everything I needed to make my 2d multiplayer games ...the part I edited out.

  • @yatrikamrutiya9376
    @yatrikamrutiya9376 4 ปีที่แล้ว

    thankyouuu so much man !!! ....i've never seen someone explain java so easily

  • @Nekyox_
    @Nekyox_ 4 ปีที่แล้ว +22

    Arf, you should use % and / to set the symbol instead of your switch
    gameBoard[2 * ((pos - 1) / 3)][2 * ((pos - 1) % 3)]

    • @Luca-hn2ml
      @Luca-hn2ml 4 ปีที่แล้ว +6

      Yea and there are other efficiency flaws in his code.
      For example the winning checks and the while loop for the cpu can be improved

    • @chriscarlisle8997
      @chriscarlisle8997 4 ปีที่แล้ว

      Dude that's ingenious!

  • @markbaker9593
    @markbaker9593 3 ปีที่แล้ว +4

    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.)

    • @zk__27
      @zk__27 2 ปีที่แล้ว

      Hello, could you please explain why after 9 moves it only checks one win scenario?

  • @gandhisFlipFlops
    @gandhisFlipFlops 2 หลายเดือนก่อน

    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.

  • @pythondoesstuff2969
    @pythondoesstuff2969 4 ปีที่แล้ว +1

    Wow I wrote my second java project with this.......
    Thanks.
    First was obviously hello world

  • @fullmetaltheorist
    @fullmetaltheorist 3 ปีที่แล้ว

    dude you are really helping me with my college work

  • @suriii978
    @suriii978 11 หลายเดือนก่อน

    Wow just wow I'm so so glad that I got this wonderful opportunity to do intership in sustem trons

  • @kshitizkaushik8092
    @kshitizkaushik8092 2 ปีที่แล้ว

    bro you helped me alot, may you live long and beautiful life.
    amen

  • @matthieug5183
    @matthieug5183 3 ปีที่แล้ว

    Awesome video for beginners in Java, thank you man !

  • @_sf_editz1870
    @_sf_editz1870 2 ปีที่แล้ว +1

    Pure talent man 😄 , god bless you

  • @MinecraftStonewideos
    @MinecraftStonewideos 4 ปีที่แล้ว

    The most important thing I learned from this video is While(true) and break; this is going to help me so much!

  • @amgnico
    @amgnico 5 ปีที่แล้ว +8

    I did my first tictactoe today, but it's X vs O without CPU

  • @MisterWealth
    @MisterWealth 5 ปีที่แล้ว +8

    This tutorial is what the gang needs! Wahooooo

  • @phenomenon7030
    @phenomenon7030 5 ปีที่แล้ว +1

    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

  • @SDILUYNTsiu39fnd
    @SDILUYNTsiu39fnd 2 ปีที่แล้ว +1

    I think you've could've made a nested for loop to iterate through the x and y indexes of the 2d array, instead of using a switch

  • @NetITGeeks
    @NetITGeeks 3 ปีที่แล้ว +1

    Thank you for helping me pass my Java class Alex and I love your intro song Kazura - My Way.

  • @paoloberi
    @paoloberi 4 ปีที่แล้ว

    Just what I was looking for, you rock and inspire men, keep it rolling

  • @NiffirgkcaJ
    @NiffirgkcaJ 9 หลายเดือนก่อน

    There are some bugs which I am unable to fix, but you're infinitely better than me! :D

  • @thanos9704
    @thanos9704 4 ปีที่แล้ว +1

    Thank you Alex lee
    Finally made my first *TicTacToe*

  • @julienl.1080
    @julienl.1080 3 ปีที่แล้ว +6

    Next (big) step : the same game with TDD + SOLID principles + clean code + java 8 lambdas (using predicates) + thinking OOP instead of procedural + writing it in a clean architecture to isolate the domain from the infrastructure.
    The goal is to have code that is sufficiently readable, flexible, maintainable and protected by tests so that it does not have to be completely rewritten every time an evolution is needed.
    Rewrite completely a tic tac toe game is not problematic, but rewrite a big and expensive application is.
    Don't write legacy code ☺️

  • @krishna-tj9ut
    @krishna-tj9ut ปีที่แล้ว

    i cant thank you enough you are a great teacher

  • @learnit2065
    @learnit2065 4 ปีที่แล้ว +1

    Help full

  • @icedtea5143
    @icedtea5143 3 ปีที่แล้ว

    Yo, you saved me like 6 hours of work and research there. Subbed!

  • @MrAnonymous-j6l
    @MrAnonymous-j6l 4 ปีที่แล้ว +2

    Smart kid. Keep up the good work!

  • @Paersik
    @Paersik 4 ปีที่แล้ว

    I'm so thankful for this video!

  • @CarlosMartinez-zu6xz
    @CarlosMartinez-zu6xz ปีที่แล้ว

    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.

  • @TrackDamagerz
    @TrackDamagerz 3 ปีที่แล้ว

    Beginner here, this was SUPER helpful, thank you! Subscribing now :)

  • @DavisTibbz
    @DavisTibbz 4 ปีที่แล้ว

    This is fabulous! You are a great instructor.

  • @essentialzmusic
    @essentialzmusic 2 ปีที่แล้ว

    Buck all of your fav teachers...this boy is certified. Thanks cuhhhh 🤣💪

  • @blackbass1422
    @blackbass1422 4 ปีที่แล้ว +1

    I'm a very young and small programer that learned the programming language "c" I don't know all of it but I know 90% of it. I love watching these videos because when I grow up being a programer is what I want to be

  • @joeyphilipp4690
    @joeyphilipp4690 4 ปีที่แล้ว +15

    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();
    }

    • @lamellama7450
      @lamellama7450 4 ปีที่แล้ว

      Yea I figured it out myself

    • @castles990
      @castles990 4 ปีที่แล้ว

      Thats what i thought

    • @anonymousone1468
      @anonymousone1468 3 ปีที่แล้ว

      Thank you for this comment. I was confused about how I should have rewritten this part.

  • @aaronangmingze8144
    @aaronangmingze8144 9 วันที่ผ่านมา

    i think I encountered a bug in checking if the piece has already been placed by either player or cpu in the while loop of the main method.
    The two while conditions should be as follows:
    while(playerPositions.contains(playerPos) || cpuPositions.contains(playerPos))
    while(playerPositions.contains(cpuPos) || cpuPositions.contains(cpuPos))
    Instead of:
    while(playerPositions.contains(playerPos) || cpuPositions.contains(playerPositions))
    while(playerPositions.contains(cpuPos) || cpuPositions.contains(cpuPositions))
    If we follow the original one, we can still run into replacing positions made by the CPU. In this case, the player can win in an example:
    first row two x, last row/last column is a O, then user enters 3 replacing the CPU placed piece at 3, giving player a win.

  • @ahnafbataineh8319
    @ahnafbataineh8319 4 ปีที่แล้ว

    i like how u divide ur method

  • @MrSir-qv3lx
    @MrSir-qv3lx 4 ปีที่แล้ว +4

    Keep up the excellent work, Alex.
    One comment - in method checkWinner, you need to move the CAT check to be outside the loop where you check for winning.
    If you don't and the ninth move is a winner, the code will still likely report CAT! because the loop is not allowed to finish checking all of the entries in the list "winning".

  • @aminajan2468
    @aminajan2468 4 ปีที่แล้ว

    Keep up the good work man, I'm supporting you.

  • @japanhunter4807
    @japanhunter4807 3 ปีที่แล้ว

    Thank you for your plain lesson!
    Making board game can expand knowledge of Array class.

  • @Name-pn5rf
    @Name-pn5rf 4 ปีที่แล้ว +1

    I just made my first tic tac toe!!

  • @zelyxc7186
    @zelyxc7186 4 ปีที่แล้ว +1

    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!

  • @monkeyseatcatfood
    @monkeyseatcatfood 3 ปีที่แล้ว

    Super helpful tutorial, Alex Lee. Really appreciate the explanations you gave.

  • @Mousymusic
    @Mousymusic 3 ปีที่แล้ว

    Awesome Job , Wrote the whole code and took me 3 hours

  • @snehakramesh8614
    @snehakramesh8614 3 ปีที่แล้ว

    the gaming program for tic tac toe was really cool.....

  • @user-zf8gy1yw1p
    @user-zf8gy1yw1p 4 ปีที่แล้ว +1

    .....best intro I've seen so far.

  • @bjr816
    @bjr816 4 ปีที่แล้ว

    I really hope to be able to build a small game like this. This is dope!

    • @Sport-word
      @Sport-word 4 ปีที่แล้ว

      m.th-cam.com/video/R9jTdJatD_I/w-d-xo.html
      Check out this beautiful tic tac toe game with UI design .. the best ever !!

  • @severosjames4341
    @severosjames4341 3 ปีที่แล้ว

    i learn a lot from you alex

  • @Odysseaa
    @Odysseaa 3 ปีที่แล้ว

    Omg this is sooo cooool, I struggled a little on something but I did it!!!

  • @taikez288
    @taikez288 4 ปีที่แล้ว

    YOOOOO ALEX YOURE AMAZING BRO
    can you make a java calculator tutorial?
    love u man youre actually cool

  • @drip-y4w
    @drip-y4w 3 ปีที่แล้ว

    This is awesome dude!!!
    I have learnt a lot from you

  • @StriveforGainz
    @StriveforGainz 2 ปีที่แล้ว

    Keep up the great work Alex!

  • @aarjuchoudhary03
    @aarjuchoudhary03 ปีที่แล้ว +1

    I spent 2:30 hours but it's awesome 👍

  • @mongaydiego
    @mongaydiego 3 ปีที่แล้ว

    Thank you, thank you, thank you. Great code. Great program. Fun with Java!

  • @exip9288
    @exip9288 2 ปีที่แล้ว

    Sen var ya sen, sen adamın dibisin.