In this lecture, we'll learn how to write the method header four and call the four different kinds of methods and there are more than four different kinds of methods, but these are the four most common kinds of methods. So what does a method header tell us? It tells us who can call the method, it tells us whether we call the method on an object or a class. It tells us the return type for the method. It tells us the name of the method, and it tells us what information we pass into the method when we call it. Let's look at the syntax for a method header in a little more detail. Here's an explanation of the syntax for a method header. So this first piece called the access modifier, tells us who can call the method. So if we make this method public then anyone can call it and if we make it private, then only other methods within this object can call it and the square brackets mean that the access modifier is optional and if we don't provide it, the default is private. The next piece of the method header tells whether we call the method on an object or on the class. If we do not provide the keyword static, then we call the method on an object but if we do include that static keyword, then it's on a class, not an object and we've seen static methods before. So the Console.WriteLine method is a static method because we call it on the console class, not on an instance of that class, not on an object. This tells us what datatype the method returns then we provide the method name and finally, we have a list of 0 or more parameters, pieces of information that get passed into the method and for each parameter that we do include, we include the data type for that parameter and a parameter name, the way that we will refer to that parameter within the body of the method. So what are the four most common kinds of methods? There's a method that doesn't have a return value and doesn't have any parameters. There is a method that does have a return value and doesn't have any parameters. There's a method that doesn't have a return value but does have a parameter and there's a method that has both a return value and a parameter. Let's take a look at those four common kinds of methods in more detail. We'll explore the four different kinds of methods in our deck class and the first kind I mentioned was a method that doesn't have a return value and doesn't have any parameters and our shuffle method is a good example of that. When we don't have a return value, we use this special keyword called void and that says this method doesn't return anything. To specify that we don't have any parameters for this method, we just don't put anything between the parentheses in the method header. So we have our access modifier. We didn't put static because this is an instance method, a method that will be called on a specific deck object. We put our return type, and this is our special void return type that says we don't return anything. We put the method name, we put open parenthesis and close parenthesis, and as I said, zero or more parameters, and in this case zero parameters. The reason that we have a void return type for shuffle is the shuffle method changes the internal state of the deck. It changes the order of the cards, but there's nothing that we have to give back to the consumer of the class that called this method. The shuffle method also doesn't have a parameter because it doesn't need any information from the consumer of the class. It can do its job without the consumer of the class providing any information. To call a method with no return value and no parameters, we put the name of the object dot the name of the method, and here between these parentheses, you can see I didn't provide any argument because this method doesn't have any parameters. The take top card method in the deck class is a good example of a method that returns something but doesn't have any parameters. As you know the take top card method returns a card object. So if we're returning something from the method, we put the data type, the return type that we're going to provide when we return something from the method, and the take top card method returns a card object. We still don't have anything between the parentheses, this method doesn't have any parameters because the take top card method doesn't need any information from the consumer of the class to actually take, and return the top card from the deck. The take top card method just takes the top card off the deck and removes it from the deck, and then returns that top card to the consumer of the class. You'll notice that if the deck is empty, we actually return null because we can't take the top card from an empty deck, and we need to indicate somehow to the consumer of the class that called this method that there is no cards to provide. The standard way to call a method that returns something is to put the name of the object, and dot, and the name of the method. This particular example doesn't have any parameters, so we don't provide any arguments here on the calling side, but we know after we call this method that we're holding a card object. Typically, we would take that card object and put it into a card variable so we can use it later or to flip it over, and to print the card, and so on. It is possible, as I've demonstrated before, to call this method and not put it into a variable, and that's just taking the top card and throwing it on the floor, we wouldn't have a reference to that card object anymore if we do it that way, we can't do anything with the card that we took off the top of the deck. The cut method in the deck class is an example of a method that doesn't return anything but does have a parameter, specifically the location at which we should cut the deck. Again, we have a return type of void to say that the method doesn't return anything, because like the shuffle method, all the cut method does is change the internal state of the deck, it changes the order of the cards in the deck by cutting the deck, but there's nothing to hand back to the consumer of the class that called this method. But the cut method does need information from the consumer of the class that called this method to know where to cut the deck. One way you can think about this perimeter is that, this parameter is like a local variable that we can use in the body of the method. We can use location, and you can see I've used it in multiple places here in the body of the method to actually have the method to do its job. The typical way to call a method with no return value but with one or more parameters, is to put the object name dot, and the method name, but this time, instead of leaving this part blank between the parentheses, we provide an argument that gets passed into the method and the parameter gets assigned the value of this argument, and we'll explore that in a little more detail in the next lecture. In case you didn't realize it, this call to cutting the deck, is cutting the deck exactly in the middle of the deck. Finally, I added a method to the deck class called take card that returns something, a card, and has a perimeter, the location of the card we want to take. This method isn't a typical use of a deck, this is good for magic tricks, pick a card, any card, but in general, when we use a deck, especially if we just deal from the top of the deck, we don't let consumers of the class just pick a card and take it from the middle of the deck or the bottom of the deck because usually that's considered cheating. But I wanted to use as an example to show a method that has a return type and a parameter. The take card method returns a card object, and it has a parameter that tells which card we should take from the deck. To call a method with a return value and a parameter, the object name.method name, I put whatever arguments the method expects here between the parentheses, and now that I'm holding a card object, I'm putting it into a variable because I want to do stuff to that card, flip it over and print it. This particular example only has one parameter. I could also do something like float mass. I can have multiple parameters. This makes no sense of the context of a card, but I wanted to show you that we can have multiple parameters. Here in the method header, if we have multiple parameters, we separate them by commas, and when we call a method with multiple parameters, we separate our arguments with commas. You've seen that before when we call the version of the instantiate method in unity, that has us provide the prefab we went to instantiate, and the world location, and the rotation of that game object that we're instantiating, we separate those three arguments with commas. We're going to get rid of this because I don't want to keep it. Now, we've looked at examples of the four different method headers and how we call methods with those four different method headers. To recap, in this lecture, we learned what information a method header provides. We learned how to write method headers for the four most common methods, and we learned how to call those four different methods as well.