4 C# Classes, Methods & User Input
This chapter covers
- Properly using classes in C#
- Working with methods to give our code functionality
- Using the console class, its methods, and properties
- Converting data with the Convert class and its methods
- Developing a number guesser minigame
Nearing the end of Part 1 – Introduction to the C# Programming Language, we slowly become more familiar with the C# development process. We find new types and shapes of coding language with each chapter that we can use to build our programs. Until now, we learned about the fundamentals of this language. We learned about variables, datatypes, randomness, operators, and conditionals and got pretty good at working in our development environment. Furthermore, we were able to build a complete, scalable project in each chapter, which will not change with this chapter.
This chapter's project, the "Guess the number" minigame, will consist of a random number that needs to be guessed by the user. Each time a user input is given, the code will compare the given number to the random number generated and tell the user if the guessed number is too high, too low, or matched. We can then keep track of the number of tries to compete with others.
This chapter's minigame project will teach us everything about user interactivity as well as introduce us in detail to classes, methods, the console class, and the Convert class. Furthermore, like always, provide us with a project ready to be vastly expanded upon.