Introduction
Methods are a fundamental programming concept. They provide code reusability, improve readability, and reduce the size of your code. Methods help you break down complex problems into modularized tasks, and help organize your code. Now that you've learned about methods, you're ready to start developing more functionality into your programs!
Suppose you're an event coordinator for a petting zoo. You must regularly coordinate visits from different schools and organize animal visits for several groups of students. You decide to write an application that helps you plan school visits. The application divides students into groups and assigns them a set of animals to visit. The students will rotate groups after they visit their assigned animals. You decide to randomize the order animals so that each school's visit is unique.
This module will guide you through the steps required to develop your petting zoo application. Your code will use methods to plan a visit for three schools, randomize the order of animals, assign students to groups, and display the results. You'll use methods that accept parameters and return values, and you'll include some optional parameters as well.
Learning objectives
In this module, you’ll practice how to:
- Use methods to perform specific tasks
- Create methods that accept require and optional parameters
- Use values returned from methods
Prerequisites
- Experience using Visual Studio Code to develop, build, and run C# console applications
- Experience using C# data types including
int,string, and arrays - Experience using
switchstatements, if-else statements, andforloops - Experience using the
Randomclass to generate a random number. - Basic understanding of C# methods