In the previous two lectures, we learned how to use a constructor to create an object we could interact with, and then we interacted with that object to get access to the state of the object through a getter or an accessor. In this lecture, we'll access the behavior of the object by calling a variety of different functions. We're starting with the code that we had last time. We're going to come down to the bottom of our code. This is called methods but we're really going to call functions. Some people call the functions in C++ methods, other people call them functions. I think we'll stick with the functions terminology here. Looking at the documentation, we can see that the deck class exposes four different functions. We'll go through them one-by-one so that we can call each of them. We'll start with the print function. We can see we don't have to provide any information as arguments when we call the print function and it prints the cards in the deck from top to bottom. Back in our code, all we have to do is say Deck.Print. Again, using this name of a variable, dot, name of a function, open parenthesis, close parenthesis. Let's go ahead and "Control F5." We see that all the cards are face down in the deck, so it refuses to print them for us. That makes sense, right? All the cards in the deck are face down and we can't see their values. This is in fact printing the deck and it's printing each of the cards in the deck. It's actually telling each of the cards in the deck to print itself but it's not giving us really good information here, but it is giving us accurate information here. You'll find that even though this print function has been provided as part of the deck, it's more useful if we work through all the cards in the deck, flipping them over, and then print the deck. But I did want to show you how we can actually call the function. The next function we'll call, so that we could actually take a look at how things are happening in the deck, is we'll call the TakeTopCard function. The TakeTopCard function also doesn't require any argument. You can't just say, give me the card that's three down from the top in the deck because that is typically considered cheating but we can take the top card. When we take the top card, it hands something back to us. It gives us a card object from the top of the deck. It removes it from the deck, but it hands us a card. I'll just comment out this print function because that's not useful to us at this point, but I'll leave it in the code so you can see how we did it. We actually can go like this. We've got a card, I'll call it card 0. There's a card class also in this DLL. You can see over here in the headers that there's a card.H file. I'll call it card 0 and I'll say Deck.TakeTopCard. Now, if we look at the documentation for the card class by looking over here and seeing there's a card class as well, we can get the rank of the card, we can get the suit of the card, we can check to see if the card is faceup, we can flip the card over, and we can print the card. Let's start by just saying Card0. Print and see what happens. When we Control F5, it tells us the card is facedown. This is more evidence that when the deck was printing itself, it was just telling each card to print itself, but each card was facedown so each card was saying, "Hey, I'm facedown." We can tell card 0 to flip itself over. Now when we run, we see that the king of spades was on the top of the deck and we took it off the top of the deck, we flipped it over, and we printed it, and we discovered that it was in fact the king of spades. Now what I'm going to do, is I'm going to go back to the deck class and I'm going to call shuffle before I take the top card. Again, we see we don't provide any information. Before I do that, let's go back to the code for a moment because I want to show you that I can actually also do this. This will compile, this will run, and you should think about what's happening, what am I doing? I'm taking the top card off the deck and I'm just throwing it away. If I then took the next top card off the deck and flipped it and printed it, I get the queen of spades because I took the first card off the deck and threw it away, so we actually can call functions that return objects to us, or ints, or floats or anything that have a return type. We can call them without putting the result anywhere, and it's just like a saying, "I don't care about the result. I'll just throw it away." You could do this if you wanted to get rid of the top five cards in the deck, you could just call take top card five times and not put it anywhere, and then start using the deck from there. That's valid syntax, in its even valid in, I'm going to say rare cases. But almost always, if a function returns a value, you should use that value somehow, either print it out right away or store it in a variable to use later or something like that. Okay, let's go to shuffling the deck. Again, I'll comment this out [NOISE]. I'm trying to space this out so that if you look at the code later, it makes some sense to you about the structure of the code. Let's shuffle the deck. [NOISE] While we won't have strong evidence that the deck actually got shuffled because we can't look at the ordering of the cards with all of the cards face down, we can at least make sure that we're not getting the king of spades off the top of the deck. I've shuffled the deck, and now I'm taking the top card, and I got the queen of clubs. The last function we have in the deck class is cut. Cutting the deck we do in fact, need to provide an unsigned int for the location at which we want to cut the deck. This is not just an int because ints have negative numbers, so saying we want to cut the deck at the negative the eighth card, that makes no sense at all. When I wrote this function, I said the parameter on the function side and the argument on the calling side needs to be an unsigned int, so it starts at zero and is always positive. Let's go call this function. Let's go ahead and cut the deck [NOISE]. First, I will show you that I can cut the deck after the 0th card. Programmers start counting at zero for very good reasons that I'll talk about later in the specialization. But I'm going to cut the deck at the 0th card, which means I'm going to cut it just past the king of spades. We know the king of spades is on the top of the deck if we haven't shuffled it when it's created, so I'm going to cut the deck, taking the king of spades off the top of the deck and putting it on the bottom of the deck. So cutting the deck just past card zero should give us the queen of spades, [NOISE] and it does, as expected. I could cut the deck just after the 13th card in the deck because we're doing 0-based counting and I should get the king of some other suit. Because I know when I built the deck, my first 13 cards were the king through the ace of spades. I know that because I wrote the class. You don't know that as a consumer of the class. I know that because I wrote the class and so I see the king of hearts. I could even figure out what order they go. Spades, hearts, diamonds, and clubs. We should have known that even before we did it. The last function here, it doesn't return anything because it's just changing the internal state of the deck. But we do provide information to tell it where we want it to cut the deck. To recap, in this lecture, we access the behavior of an object by calling a variety of functions, and we used the documentation to make sure that we were calling those functions properly.