1
//확인또는취소.cs
2
using System;
3
4
namespace 확인또는취소
5
...{
6
public class Window
7
...{
8
//[1]필드
9
private static string _Status;
10
//[2]속성
11
public static string Status
12
...{
13
get ...{ return _Status; }
14
set ...{ _Status = value; }
15
}
16
//[3]메서드
17
public static void Alert(string message)
18
...{
19
Console.WriteLine(message);
20
}
21
public static bool Confirm(string message)
22
...{
23
Console.WriteLine(message);
24
Console.Write("확인 또는 취소(y/n): _\b");
25
if ((char)(Console.Read()) == 'y')
26
...{
27
return true;
28
}
29
else
30
...{
31
return false;
32
}
33
}
34
//[4]생성자
35
static Window()
36
...{
37
_Status = "완료";
38
}
39
}
40
41
public class JavaScript
42
...{
43
//[!]메서드
44
public static void Check()
45
...{
46
if (Window.Confirm("정말로 삭제하시겠습니까?"))
47
...{
48
Window.Alert("삭제됨.");
49
}
50
else
51
...{
52
Window.Status = "삭제안됨.";
53
}
54
}
55
}
56
57
//[0]델리게이트
58
public delegate void EventHandler();
59
public class Input
60
...{
61
//[1]필드
62
private static string _Type;
63
private static string _Value;
64
//[2]속성
65
public static string Type
66
...{
67
get ...{ return _Type; }
68
set ...{ _Type = value; }
69
}
70
public static string Value
71
...{
72
get ...{ return _Value; }
73
set ...{ _Value = value; }
74
}
75
//[3]이벤트
76
public static event EventHandler Click;
77
//[4]이벤트 처리 메서드
78
public static void OnClick()
79
...{
80
if (Click != null)
81
...{
82
Click();
83
}
84
}
85
}
86
87
public class Html
88
...{
89
public static void Main(string[] args)
90
...{
91
//[1]속성 지정
92
Input.Type = "Button";
93
Input.Value = "삭제";
94
//[2]이벤트 등록
95
Input.Click += new EventHandler(
96
JavaScript.Check);
97
//[3]이벤트 발생
98
Input.OnClick();
99
//[4]현 상태 출력
100
Console.WriteLine(Window.Status);
101
}
102
}
103
}