티스토리 뷰
1 interface Command{
2 public function execute();
3 }
///////////////////////////////
1 class Light{
2 private var name:String;
3 public function Light(name:String){
4 this.name = name;
5 }
6 public function lightOn():Void{
7 trace(name+" : 불을 켜다");
8 }
9 public function lightOff():Void{
10 trace(name+" : 불을 끄다");
11 }
12 }
/////////////////////////////////
1 class LightOffCommand implements Command{
2 private var light:Light;
3
4 public function LightOffCommand(light:Light){
5 this.light = light;
6 }
7 public function execute(){
8 light.lightOff();
9 }
10 }
////////////////////////////////////
1 class LightOnCommand implements Command{
2 private var light:Light;
3
4 public function LightOnCommand(light:Light){
5 this.light = light;
6 }
7 public function execute(){
8 light.lightOn();
9 }
10 }
/////////////////////////////////////
1 class RemoteControl{
2 private var onCommands:Array;
3 private var offCommands:Array;
4
5 public function RemoteControl(){
6 onCommands = new Array();
7 offCommands = new Array();
8 }
9 public function setCommand(slot:Number, onCommand:LightOnCommand, offCommand:LightOffCommand):Void{
10 onCommands[slot] = onCommand;
11 offCommands[slot] = offCommand;
12 }
13 public function onButtonWasPressed(slot:Number):Void{
14 onCommands[slot].execute();
15 }
16 public function offButtonWasPressed(slot:Number):Void{
17 offCommands[slot].execute();
18 }
19 }
//////////////////////////////////////
1 class RemoteControlTest
2 {
3 public function RemoteControlTest ()
4 {
5 init ();
6 }
7 public function init () : Void
8 {
9 var remote : RemoteControl = new RemoteControl ();
10 var light : Light = new Light ("스텐드");
11 var lightOn : LightOnCommand = new LightOnCommand (light);
12 var lightOff : LightOffCommand = new LightOffCommand (light);
13 remote.setCommand (0, lightOn, lightOff);
14 remote.onButtonWasPressed (0);
15 remote.offButtonWasPressed (0);
16 }
17 }
2 public function execute();
3 }
///////////////////////////////
1 class Light{
2 private var name:String;
3 public function Light(name:String){
4 this.name = name;
5 }
6 public function lightOn():Void{
7 trace(name+" : 불을 켜다");
8 }
9 public function lightOff():Void{
10 trace(name+" : 불을 끄다");
11 }
12 }
/////////////////////////////////
1 class LightOffCommand implements Command{
2 private var light:Light;
3
4 public function LightOffCommand(light:Light){
5 this.light = light;
6 }
7 public function execute(){
8 light.lightOff();
9 }
10 }
////////////////////////////////////
1 class LightOnCommand implements Command{
2 private var light:Light;
3
4 public function LightOnCommand(light:Light){
5 this.light = light;
6 }
7 public function execute(){
8 light.lightOn();
9 }
10 }
/////////////////////////////////////
1 class RemoteControl{
2 private var onCommands:Array;
3 private var offCommands:Array;
4
5 public function RemoteControl(){
6 onCommands = new Array();
7 offCommands = new Array();
8 }
9 public function setCommand(slot:Number, onCommand:LightOnCommand, offCommand:LightOffCommand):Void{
10 onCommands[slot] = onCommand;
11 offCommands[slot] = offCommand;
12 }
13 public function onButtonWasPressed(slot:Number):Void{
14 onCommands[slot].execute();
15 }
16 public function offButtonWasPressed(slot:Number):Void{
17 offCommands[slot].execute();
18 }
19 }
//////////////////////////////////////
1 class RemoteControlTest
2 {
3 public function RemoteControlTest ()
4 {
5 init ();
6 }
7 public function init () : Void
8 {
9 var remote : RemoteControl = new RemoteControl ();
10 var light : Light = new Light ("스텐드");
11 var lightOn : LightOnCommand = new LightOnCommand (light);
12 var lightOff : LightOffCommand = new LightOffCommand (light);
13 remote.setCommand (0, lightOn, lightOff);
14 remote.onButtonWasPressed (0);
15 remote.offButtonWasPressed (0);
16 }
17 }
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 플래시
- BitmapData
- Blog
- ColorCop
- Information Ring
- 사진
- flash
- Iterator
- 디자인분류
- TemplateMethod
- graph
- Design Patterns
- StrategyPattern
- bloger
- 디자인패턴
- UI
- PhoneUI
- 구글
- 디자인 체계도
- UI디자인
- DESIGN
- 터치폰
- ActionScript
- Observer
- AS
- 제퍼슨 한
- 밍밍이
- Decorator
- 가이드라인
- 액션스크립트
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함