Home > Net >  Help bosses that how to write c #
Help bosses that how to write c #

Time:09-26

1. Write a Ticket class, there is a distance attribute (in the way of constructing this attribute is read-only, assignment), not a negative, there is a Price attributes, Price attribute is read-only, and according to the short distance calculation Price Price (1 yuan/km) :
0-100 km fare discount
Total - 101-200 km 9.5 discount
- 201-300 km total 9 discount
- a total of 300 kilometers or more 8 fold
There is a way, can display the ticket information, 90 kilometers, 90 dollars,
- test the above class
- use the constructor

2. Write a Reporter and a Programmer, Drive class, they all have a way of greeting, the difference is:
Reporter class "hello way:" my name is zhang SAN, my hobby is secret, my age is 34 years old, I am a male, paparazzi
Programmer class "hello way:" my name is sun quan, my age is 23 years old, I am a boy, my length is 3 years,
Drive type "hello way:" my name is Michael, my age is 43 years old, I am a man, my driving experience is 23 years old,
(use inheritance)

3. The manager at eleven o 'clock clock in, staff clock in at 9 o 'clock, programmers don't punch (virtual method is used to implement)

CodePudding user response:

Class to listen well, the first question even if you're not the strategy pattern, at least the if... Else should also, the second and the third is to define the base class and subclass, then override, questions should be your post you write the code, we all help you analysis analysis, not directly to the code

CodePudding user response:

The teacher teach all listen to not understand, also hope to have you here to teach understand

CodePudding user response:

I don't see the topic request to do,,, because don't understand the inherited virtual method is what, and use a constructor is to how to use

CodePudding user response:

Public class Employee
{
Public virtual void DaKa ()
{
Console. WriteLine (" employees to clock in at 9 o 'clock!! ");
}
}
Public class Maneger: Employee
{
Public override void DaKa ()
{
Console. WriteLine (" manager at eleven o 'clock clock ");
}
}
Public class Pragrammer: Employee
{
Public override void DaKa ()
{
Console. WriteLine (" programmers don't punch ");
}
}
The static void Main (string [] args)
{
The Employee em=new Employee ();
Maneger ma=new Maneger ();
Pragrammer pa=new Pragrammer ();
The Employee [] emps={em, ma, pa};
For (int I=0; i {
Emps [I] DaKa ();
}
Console.ReadKey();
}
}
  •  Tags:  
  • C#
  • Related