Rock Paper Scissors Game | C++ Example

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

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

  • @carlojohnl.5515
    @carlojohnl.5515 11 หลายเดือนก่อน +3

    You are better than my teacher, your explanations are on point. Thank you for this Sir!

  • @djprgotube
    @djprgotube 16 วันที่ผ่านมา

    Nice vid! I used roughly 60 lines of code while making my own but you made it look easy! I learned a lot from this vid! Huge thanks!

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

    Great video, i'll be going through your cpp code examples these are very helpful

  • @zoebulle9102
    @zoebulle9102 21 วันที่ผ่านมา

    hiya guys. ai random thrower works well. only issue was my "Draw! Play again" showed with each game. Then I noticed in my if statements i used = and not ==. One asigns and one means equal. Something to keep in mind haha! Thanks for the video. I'm working on control structures for my exam and I think I've got a good understanding of if statements and the do while loop

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

    Thx for the video , a question related to c++ , whats the difference between enum and #define ?

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

      You're welcome Elie! :-) And great question too.
      #define is a preprocessor directive, where the preprocessor is an early stage of the compilation of a C/C++ program. When we use define to define a preprocessor constant, i.e. a macro, the compiler's preprocessor phase will replace all occurrences of a preprocessor constant like 'SCISSORS' with '3'. So it's a helpful way of defining constant values to be used throughout our program. It can improve the readability of the program, by using something like 'SCISSORS' instead of '3' directly. And if the constant value needs to change, we can change it one place.
      enum is a user-defined type, and the values of the type are a group of constants that we can define. And by 'user-defined' we mean 'programmer-defined', not the user of the software. It plays a similar role in that we can define an enum with values like for example ROCK, PAPER, SCISSORS, and then use those values throughout the program even though the 'real' underling value will be an integer. This will improve code readability. With enum we can declare values using the type, with preprocessor constants we aren't really defining a 'type'. It would make sense to use enum if we want to declare variables, structs and/or arrays that will store and use values of this type (really integers though).
      I have some videos on these topics. :-)
      enum Tutorial: th-cam.com/video/oQFN_oi7k3E/w-d-xo.html
      constants Tutorial: th-cam.com/video/r0OuA1Q8jOo/w-d-xo.html

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

    Could you not use switch case or am I noob

  • @jungleboi9009
    @jungleboi9009 3 หลายเดือนก่อน

    what if i want to keep track of who wins and loses

  • @DMJ-wx9wq
    @DMJ-wx9wq ปีที่แล้ว

    What IDE / Software are you using? its really nice and id like to use it as well

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

      I am using Xcode on Mac OS. :-)

    • @DMJ-wx9wq
      @DMJ-wx9wq ปีที่แล้ว

      @@PortfolioCourses Yikes, I have a windows Device. Can you Suggest anything similar for windows?

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

      Visual Studio or Visual Studio Code should be good on Windows. :-) This video might help: th-cam.com/video/gq_ZXCuRhU4/w-d-xo.html.

  • @Raul-0303
    @Raul-0303 ปีที่แล้ว

    how can I learn C programming in 6 months? I have failed the programming exam in my first semester this year. I should focus only on solving problems? If yes, can you recommend me some websites where I can solve problems?

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

      That's a great question Raul. I'm sorry to hear that about the programming exam, but I can try to offer some advice. So in terms of the resources on this channel that may be able to help you, there is this C Programming for Beginners course: th-cam.com/video/ssJY5MDLjlo/w-d-xo.html. Then there is this playlist of C Programming Tutorial covering lots of concepts in more depth: th-cam.com/video/gq_ZXCuRhU4/w-d-xo.html. And there is also this playlist of C Programming Examples covering solutions to many programming problems: th-cam.com/video/sepK5w4Uep0/w-d-xo.html.
      In terms of "what to focus on", the truth is you very likely want to go back and forth between trying to problems, and consuming materials like TH-cam videos, textbooks and online resources. Because it's difficult to solve problems without knowing the background concepts, but at the same time test questions will likely involve application of concepts so the problem solving is important too.
      Getting better at programming takes a lot of people a long time, because it's a new type of problem solving. But it's not like solving problems in say for example, a high school physics course, where we re-arrange and equation and put in numbers to perform a calculation. Programming often involves solving problems that are very "new" and "novel", or at least, they feel that way. New programmers will often say "I knew all the concepts, but I didn't know where to start or how to put them all together".
      That's where going over many, many problem solutions can help you. Because what happens is as you go over solutions to problems, your brain builds a "toolbox" or "library" of old solutions that it can reference later. :-) So if you go over many problems involving file access, you begin to notice patterns like opening the file, reading data, closing the file. And then when you see similar problems, over time it becomes easier to recognize that things you have seen in old solutions can be re-applied, perhaps with some tweaking. Almost nobody can just write amazing programs to solve new problems from scratch, most of us have to spend a long time going over other solutions before we can begin to more easily see patterns and apply prior knowledge to new problems.
      So I would actually recommend going over many, many solutions to problems. And once you have gone over many in an "area" of C, like arrays, or strings, or file access, then trying to solve new problems in that same "area". You might be surprised that it feels easier than before somehow.
      I have started this playlist to help new programmers in particular: th-cam.com/video/RDvlJaeGqyU/w-d-xo.html.
      There's lots of great websites for C practice, I like this one but I suspect there are "cooler" ones out there like CS50 or CodingBat, etc: www.w3resource.com/c-programming-exercises/. :-)

  • @GulAsia-u1o
    @GulAsia-u1o ปีที่แล้ว

    Hello sir .....
    I need this program's source code.....

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

      There is a link in the video description. :-)

    • @GulAsia-u1o
      @GulAsia-u1o ปีที่แล้ว

      Link is Not open why sir.....?

  • @hi5wifi-s567
    @hi5wifi-s567 ปีที่แล้ว

    Can this write abit more concise ?

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

      I strongly suspect it's possible. :-) It may come at the "cost" of making the code a bit harder to read. But maybe we could put the win-los-draw states into a 2D array, and use the 2D array to decide the winner, so we could check game[player_throw][ai_throw] (or something like that). That's the only way I can think to do it off the top of my head, maybe someone else can chime in with another/better idea! :-)

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

    ai threw scissors 4 times in a row with random?

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

      I didn't notice that, but yes. :-) The code/game is OK though, the AI will throw other things, that's just how it came out when I tested it in the video.

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

      @@PortfolioCourses gotcha, its definitely interesting using current time to get a random value. will use in the future

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

      Awesome! :-)

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

    why ai always throw a scissors...

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

      Sounds like something is wrong with random number generation if you are getting that result, this program in the video won’t always throw scissors.

  • @jon-markrivero787
    @jon-markrivero787 4 หลายเดือนก่อน

    your telling me by random chance AI throws scissors 4 times in a row…

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

      I know eh! The odds of getting 4 of something in a row are about 3.6% I think, so it's unlikely but not astronomically unlikely. :-)