11일차 클래스(15)
Console Programming/C# Console 2019. 10. 4. 14:49
|
Crop.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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax42
{
public class Crop
{
//data
//name
//hp
public string name;
public int maxHp = 30;
public int hp;
public Crop(string name)
{
this.name = name;
this.hp = this.maxHp;
}
public void Hit(Monster attacker)
{
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
Monster.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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax42
{
public class Monster
{
//data
//name
//damage
public string name;
public int damage = 5;
public Monster(string name)
{
this.name = name;
}
public void Attack(Crop crop)
{
crop.Hit(this);
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
Game.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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax42
{
public class Game
{
//data
//name
public string name;
public Game(string name)
{
this.name = name;
}
public Monster MakeMonster(string name)
{
var monster = new Monster(name);
return monster;
}
public Crop MakeCrop(string name)
{
var crop = new Crop(name);
return crop;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
App.cs
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax42
{
public class App
{
public App()
{
var game1 = new Game("게임 관리자");
var monster1 =game1.MakeMonster("쥐");
var crop1 = game1.MakeCrop("호박");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
'Console Programming > C# Console' 카테고리의 다른 글
11일차 클래스(17) (0) | 2019.10.04 |
---|---|
11일차 클래스(16) (0) | 2019.10.04 |
11일차 클래스(14) (0) | 2019.10.04 |
11일차 클래스(13) (0) | 2019.10.04 |
11일차 클래스(12) (0) | 2019.10.04 |