10.03 11일차 클래스 (29) 질럿,드라군 공격사거리
Console Programming/C# Console 2019. 10. 8. 03:10
|
Unit.cs | |
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp1007
{
public class Unit
{
//data
//name
//damage
//hp
//attackRange
public string name;
public int hp;
public int maxHp;
public int damage;
public int attackRange;
public Unit(string name, int maxHp, int damage, int attackRange)
{
this.name = name;
this.maxHp = maxHp;
this.hp = maxHp;
this.damage = damage;
this.attackRange = attackRange;
}
//function
//Attack
//Hit
public void Attack(Unit target, int distance)
{
if(distance>this.attackRange)
{
Console.WriteLine("사거리가 되지 않아 공격에 실패 했습니다");
return;
}
target.Hit(this);
}
public void Hit(Unit attacker)
{
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
49라인이 38라인과 중복되고
51라인의 {this.hp}{this.maxHp}가 곱연산으로 나와서 결과가 610으로 나왔다.
'Console Programming > C# Console' 카테고리의 다른 글
백준 2675 문자열 반복 (0) | 2019.10.08 |
---|---|
백준 11809 알파벳 찾기 (0) | 2019.10.08 |
11일차 클래스(23) (0) | 2019.10.04 |
11일차 클래스(22) (0) | 2019.10.04 |
11일차 클래스(21) (0) | 2019.10.04 |