today im doing some coding on a simple console app i like to play with. if you want to lear the basics of c# stop on in! so far so good. come and check it out! dont forget to hop into the live chat and ask some questions or just hang out!
Want to send me something? Technivorous 902 n Hughes Blunt Sd 57522
Hey, yo, and welcome guys if there's anybody out there
We're just doing some console programming today. Just kind of brushing up on some skills. It's been a while. I wanted to get back into
Playing around with this stuff so
basically, I've made a
Simple console program with a few different options in here right now. I can see my game selection screen
Or I can
Learn how to type
Hit com
Help or command for this menu here. I can
print a random quote and then I have
My game so far. I only have tic-tac-toe here
And we'll run through this real quick
It crashed because I typed 33 instead of 3. Let's take care of that real quick. That's one of the problems. I was having with
The tic-tac-toe game so
we need to parse the input of
What whoever is turn it is is putting in there right now. It is selecting so I can only
put in one integer number and
When I put in anything that is more than that I get an error, so let's see here in
class
Let's find
Yeah, and like I said, no ultimate goals here today
If you have any questions, feel free to ask them if you have any suggestions, I'm open to those too
Definitely. I always like to check out
other people's ideas and get their input so
Okay gaming so right here basically I'm checking to see if hang on one second
All right, no, I got dropped there for a second we should be back up and going here in a second
Okay, so this is basically what I was looking for. This is at my game input. I'm basically checking to see
Whose turn it is here, and then I'm checking to see if I already input
This is the method that takes my two integers
So there's probably a couple different ways to do this this is actually getting called by another method
here
so
Stuffs from before I had both of these two different turns here. Let's
Check this out. So I'm basically grabbing the grid number XY
if it's equal to one I
am
Basically setting it here. So
Nope, that's computer's turn. That's not where I want to be
Okay, this is this is where I'm having the issue right here
So right now I'm converting it to an int and then I'm using that int to pass into game input. So
Since I only have three rows these are one digit numbers
Let's make another method
Or if I punch in two numbers
This method is only going to take
One int and that is going to be
Column and that's because if I make the mistake of hitting two numbers, it's probably gonna be that first time. So
Let's generate this gonna look exactly like the other method we're using here
So we'll take this
copy it and
Basically, we're overloading this method by changing this into just one here. So and in this case
I'm going to need to take column and parse it into two separate numbers because
If I only have one int just trying to think of the best way to do this, so
Let's see
Let's do this
Well, it's even easier. All right
In this case, we're putting it back and then we can do
Now I'm just being a smart aleck, that's a poor choice of variable there, but it don't really matter so
so
This case it's going to be
index equals
So basically we need to get these two numbers I don't really need the length
All right, so let's try it out just basically undo all of that crap that we just did so let's
Stop this
Get rid of this whole method
We're gonna try this a different way. It's the most beautiful part about coding
You don't like it. Just get rid of it
Do it again
so
So I just had an idea
That I think will work better, but I guess it depends
all right, so let's
Do I have to exit the game to get back to restarting the console?
so
What's up? What's up folks? I'm losing my voice a little bit. That's why I'm not talking too much, but let's see if this works
You can't see that. Yeah
So fine, we'll do it this way don't need to pass anything through
In fact, that's okay. Let's see what happens here. We'll try it again
Let's see what other quotes are only a few
Illustrated by how many times it'll play the same one now, but there are different ones
All right, that works with back to the main menu, okay, so
So I have this list this is random lines basically
I have a static instance of this in here and it runs in my run startup system loading
List full of lines this basically where it gets those quotes. So if anybody wants to see a quote
I'm not really making a game. I'm just kind of messing around with code
and
Taking suggestions ideas things like that there. That was tic-tac-toe
Um, I am gonna add some more games to this little console app that I'm doing right now, though. I need
quotes to add to
Quote generator for when we open this little console app. So let's try
Some CC in the same thing over and over again
All right, that's been up just keep busy basically when you take a look at this little method here
Basically this is basically
Counting the number of lines grabbing a random line and returning that so then in my main program
when I type in
Check that's my game menu input and
Main menu input when I type quote it uses that
Instance that our line instances grab a line and pull it in and it returns whatever random string I get so we can try
This out again. Check out some of those new strings as they pop up
Just for shits and giggles it's a little bit a little bit of fun
I like to keep up on my coding skills
I'm really really tired right now guys. Sorry, and I'm a little bit rusty
I've been doing a lot of 3d printing things like that if you'd like to check out 3d
Printing and you don't know much about it. Definitely do that if you're here for the 3d printing
Coding is a very valuable tool to have in
The 3d printing realm so I am the walrus. Let's see. What else we got
Bacon
Blows
Yeah, so
Cool. Also, this is in my
Main menu input. So if I type something random and it doesn't understand it just says I don't understand
So if it's not listed in this specific commands, it'll do that because otherwise it'll just drop out
So here are the commands that I have so far
If I type play games or game it brings up the game menu you saw that game a little bit earlier
it was just a tic-tac-toe hit the number to play it and
Computer is not very good. Would you like to play again? I could type yes. Yeah, or hit the Y button
I'm just gonna hit no anything else you hit other than yes, or the Y button will kick you back out
So then it's gonna give us up back to the main menu and a little quote here. So
This is the first simple little application I put in here and
That reminds me. Let's stop this. Let's go up in here
And we have a games menu. How about
an applications menu
Because I think we'll do a little couch real quickly
I'm basically copying and pasting a lot of this. It's a lot of it's gonna be the same
So I'm just kind of doing a little commenting trying to keep track of things
I'm not using any of these strings. They're not gonna do anything for me. So we're gonna change
Want anything to happen there?
So absolutely, okay, so we need to add a command in here else if
for the apps
They don't have the answer not to make it it's gonna be a similar to this
Apps menu
Okay, so everything should be buttoned up there
Display command. I know there's a few more commands. I put in there. I don't really need to list them all brings up
Let's try this out. See if we have everything where we need it
All right, so we now have the option to type apps or app
And it brings up the calculator now if I hit one in this situation
It drops me out because I don't have anything handling that so
we need to do is create a
Actually, I need to get rid of this before it screws me
Don't worry, there's nothing in that. Okay, so right-click
All right, so we have this
We're gonna need a
Constructor that'll allow me to make my own calculator in here
Using it
We'll just call it calc
Okay, so
That should about do it for that part
so
Like I said, I know I'm losing my voice guys. I'm sorry. I'm gonna take a drink here. See if that helps a little
All right, yes, it's a little bit better, okay
so
now
In order to build my calculator out. I have to
When creating a new calculator, we're gonna go in here and we do that. It's going to
Call this method public calculator, this is actually a
Constructor, it's basically what's gonna allow me to build this calculator. I don't have anything coming into it
It's just empty right now. But the first thing I want to do is run a method to actually print something. So
Let's do
Calc welcome
Then we have to make that method so we're gonna make this a private void
calc
welcome
console dot write line
That's not what I meant
right line and
End quote there
and now again
if I open this and I run the
Calculator welcome class or in there, excuse me
If I open a calculator and then I run this method
It's going to write this line and then since it's not doing anything after it's going to drop right out. So
console
Read line this and tell it to wait until it gets input before doing anything at that point once I input
Since there's never anywhere to go. It is still gonna kick us out, but this will at least allow this to show
So let's go back in here
We have to set our apps menu
check apps menu
string equals
one
And this is an exit string that'll bring us back to the main menu if we type exit escape main menu main or menu
Actually put X in there too, but that is gonna be good enough to open our calculator
Let's try it out
We got an error somewhere. So
All right, welcome to the calculator app now the next thing we want to do is get rid of this here so
when we open our calculator
First thing we want to do is clear the console
For now the type today
Then we will print all right, and then we're gonna go for a
Another method for parsing the input of what we put in so
Let's start with
so we're gonna change this to a
string
string C string
This is gonna get us the return from this method here
And that is actually going to let's see
So we're still telling it to wait for input basically we're telling it we want to get back a string
And then we're gonna return
Okay
This is basically saying what I'm gonna get out of this string. So now we have this string C string. That is our calc input
Now we need to parse it. So
Parse C string
Okay, so now if I were to type something into the calculator such as 1 plus 1 it would concatenate that into a
String and basically I'm passing that string into this to parse it in order to separate the ones from the pluses
if you understand what I'm saying, so this is basically going to
differentiate
The different numbers and the different operators that are included in that string so in order to do that I need to
identify those operators
identify where they are placed within that string what position they're at and then I need to get substrings of that string and create a
basically a string array
Containing each of my numbers and operators in the proper order
So that's gonna take a little bit of typing and it's not very fun to watch. So
I'm definitely gonna keep going here. But for right now, I think I am going to pause this video
I will be back on in about an hour. I am also I got the kids tonight
so we are getting ready to do dinner here and
then I shall return but please please please leave a like and I would be very very happy to see you in the
continuation of this video