The problem: When we wrote our calculators in the past, we often added just two values. But what if the user wants to add 3 variables, or more? Would we call our methods add2, add3, and so on?
The solution: Overloading allows us to write a method with the same exact name, but with a different number of parameters. Java will use the different parameters to identify the actual method you are trying to call.
Overloading works for methods and constructors. What if the user doesn’t provide you with a gamerTag, but we wrote the constructor to take a gamerTag? Then we can write another constructor that can set default values instead.
The problem: So we are writing a player class, but what if we write another class that handles the storyline. If we make the players in main, how do we get them over to the storyline to actually play the game?
The solution: Sending arguments. We can send players as arguments just like we do with int, and more.
Additions to Player Class
1. Add an overloaded constructor for default values.
2. Copy & Paste the fight class from example III and create a new file in the same directory as your Player & Main class.
3. In Main, send multiple players as arguments to “fight” and print the winner.
4. Overload the fight method to take 3 players and have all three dual.