11일차 클래스(20)

Console Programming/C# Console 2019. 10. 4. 14:59
 
Skill.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;
using System.Threading.Tasks;
 
namespace Syntax47
{
    public class Skill
    {
        //data
        //name
        public string name;
        public Skill(string name)
        {
            this.name = $"스킬({name})";
            Console.WriteLine($"{this.name}이 생성되었습니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
Champion.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
using System;
using System.Collections.Generic;
 
namespace Syntax47
{
    public class Champion
    {
        //data
        //name
        //skill
        public string name;
        public Skill skill;   
        public Champion(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 생성되었습니다.");
        }
        //function
        //GetSkill
        //UseSkill
        public void GetSkill(Skill skill)
        {
            this.skill = skill;
            Console.WriteLine($"{this.name}이(가) {skill.name}을 부여받았습니다.");
 
        }
        public void UseSkill()
        {
           
            Console.WriteLine($"{this.name}이(가) {this.skill.name}을 사용했습니다.");
 
        }
 
    }
}
 
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
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax47
{
    public class Game
    {
        //data
        //name
        public string name;
        public Game(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 생성되었습니다.");
 
        }
 
        //function
        //MakeChmapion
        //MakeSkill
        public Champion MakeChampion(string name)
        {
            var champion = new Champion(name);
            return champion;
        }
        public Skill MakeSkill(string name)
        {
            var skill = new Skill(name);
            return skill;
        }
 
    }
}
 
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
23
24
25
26
27
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax47
{
    public class App
    {
        public App()
        {
            var game1 = new Game("게임관리자");
 
            var champion1 = game1.MakeChampion("루시안");
            var skill1 = game1.MakeSkill("빛의 심판");
 
            champion1.GetSkill(skill1);
            champion1.UseSkill();
 
 
            
        }
 
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

'Console Programming > C# Console' 카테고리의 다른 글

11일차 클래스(22)  (0) 2019.10.04
11일차 클래스(21)  (0) 2019.10.04
11일차 클래스(19)  (0) 2019.10.04
11일차 클래스(18)  (0) 2019.10.04
11일차 클래스(17)  (0) 2019.10.04
: