Fourth. Methods of in-depth classes 1. constructors
Construct: Method name and class name are the same, no return value
No parameter constructor
With parameter constructors
Construct the build policy:
Note: In C #, when we define a class, the default is to generate a class name
A parameterless construct of the same name, but if we customize any one of the parameter constructs, then
The system no longer helps us to generate a non-parametric structure, in real development, we recommend that you define
Two constructors, one without parameters, and one with parameters.
2. Method overloading
Parsing: Multiple methods in the same class that have multiple method methods with the same name but different parameter lists (number, order, type) can form overloads, and the return value type of the method does not have a semi-gross money relationship
The following two methods can form a method overload
public void Say (String name,int age)
{
}
public void Say (int age,string name)
{
}
3. Interaction between objects
Order ordering System
Customer: Point
/* Waiter: Record guest order
* Waiter: Submit menu to Chef
* Chef: Cook according to the menu
* Chef: Remind the food to be finished
* Waiter: Pass the dish (will be done to the customer)
* Customer: Dining
Menu class
Properties: Which customer (client) the menu belongs to
Which table is the menu (ID)
What the customer ordered (meallist)
Customer Category
Method: Order
public void order (waitress Waitress,order order)
Meal
Eat
Waiter class
Record Guest Order
GetOrder (Order order)
Submit a menu to the chef
Sendorder (Chef chef)
Chuan Cai
Transcook ()
Chef class
Get Menu
Cook cooking
Remind the food to be finished
Depth. NET platform and C # programming notes