forked from WeihanLi/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestPaper.cs
More file actions
100 lines (84 loc) · 2.46 KB
/
TestPaper.cs
File metadata and controls
100 lines (84 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
namespace TemplateMethodPattern
{
/// <summary>
/// 金庸小说考试试题
/// </summary>
internal class TestPaper
{
protected string StudentName { get; set; }
public void TestResult()
{
Console.WriteLine($"学生 {StudentName} 的试卷:");
TestQuestion1();
TestQuestion2();
TestQuestion3();
Console.WriteLine();
}
private void TestQuestion1()
{
Console.WriteLine("杨过得到后来给了郭靖,炼成倚天剑、屠龙刀的玄铁可能是 [ ]\r\na.球磨铸铁 b.马口铁 c.高速合金钢 d.碳素纤维 ");
Console.WriteLine($"答案:{Answer1()}");
}
private void TestQuestion2()
{
Console.WriteLine("杨过、程英、陆无双铲除了情花,造成 [ ]\r\na.使得这种植物不再害人 b.使一种珍稀物种灭绝了 c. 破坏了那个生物圈的生态平衡 d.造成该地区的沙漠化");
Console.WriteLine($"答案:{Answer2()}");
}
private void TestQuestion3()
{
Console.WriteLine("蓝凤凰致使华山师徒、桃谷六仙呕吐不止,如果你是大夫,会给他们开什么药 [ ]\r\na.阿司匹林 b.牛黄解毒片 c.黄连 d.让他们喝生牛奶 e.以上都不对");
Console.WriteLine($"答案:{Answer3()}");
}
protected virtual string Answer1()
{
return "";
}
protected virtual string Answer2()
{
return "";
}
protected virtual string Answer3()
{
return "";
}
}
internal class TestPaperA : TestPaper
{
public TestPaperA()
{
StudentName = "路人甲";
}
protected override string Answer1()
{
return "b";
}
protected override string Answer2()
{
return "c";
}
protected override string Answer3()
{
return "a";
}
}
internal class TestPaperB : TestPaper
{
public TestPaperB()
{
StudentName = "吃泡面乙";
}
protected override string Answer1()
{
return "c";
}
protected override string Answer2()
{
return "b";
}
protected override string Answer3()
{
return "a";
}
}
}