수업 007 (04.13 2020) Hong vs Lim Again
2020. 4. 13. 11:57
728x90
1. Class 'App'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study._8_2
{
class App
{
public App()
{
Character hong = new Character("홍길동");
Character lim = new Character("임꺽정");
}
}
}
|
2. Class 'Character' / ** 주체 & target 확인!
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study._8_2
{
class Character
{
public string name;
public Character(string name)
{
this.name = name;
Console.WriteLine("{0}이 생성되었습니다.", this.name);
}
// atatck
public void attack(Character target) // 나=때리는 주체=홍길동, 타겟=맞는 주체=임꺽정
{
}
// is hit
public void Hit(Character target) // 나=맞는 주체=임꺽정, 타겟=때리는 주체=홍길동
{
}
}
}
|
3. Result (Alt+printscr)

4. 3번 공격// Class'App' & 'Character'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study._8_2
{
class App
{
public App()
{
Character hong = new Character("홍길동");
Character lim = new Character("임꺽정");
hong.Attack(lim, 3);
}
}
}
|
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study._8_2
{
class Character
{
public string name;
public Character(string name)
{
this.name = name;
Console.WriteLine("{0}이 생성되었습니다.", this.name);
}
// atatck
public void Attack(Character target, int attackCount) // 나=때리는 주체=홍길동, 타겟=맞는 주체=임꺽정
{
for (int i = 0; i < attackCount; i++)
{
}
}
// is hit
public void Hit(Character target) // 나=맞는 주체=임꺽정, 타겟=때리는 주체=홍길동
{
}
}
}
|
|
5. Result (3times)

728x90
'C# > Study' 카테고리의 다른 글
수업 007 (04.13 2020) TankMode/SeizeMode (0) | 2020.04.13 |
---|---|
수업 007 (04.13 2020) Barracks (enum, id, unit type, return) (0) | 2020.04.13 |
수업 004 (04.08 2020) (0) | 2020.04.08 |
수업 003 (04.07 2020) (0) | 2020.04.07 |
수업 003 (04.07 2020) // Hero vs Monster with Random Critical Attack (0) | 2020.04.07 |