11일차 클래스(16)

Console Programming/C# Console 2019. 10. 4. 14:51
 
Resource.cs
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax43
{
    public class Resource
    {
        //data
        //name
        //gold 100ea
        public string name;
        public int gold = 100;
        public Resource(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
 

 

 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax43
{
    public class Unit
    {
        //data
        //name
        public string name;
        public int output = 10;
        public Unit(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 생성되었습니다.");
        }
        //function
        //VeinMine
        public void VeinMine(Resource resource)
        {
            resource.gold = resource.gold - this.output;
            Console.WriteLine($"{this.name}이 {resource.name}을 채취하였습니다. +{this.output}");
          
        }
    }
}
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax43
{
    public class Game
    {
        //data
        //name
        public string name;
        public Game(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 생성되었습니다.");
        }
        //function
        //MakeResource
        //MakeUnit
 
    }
}
 
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;
using System.Threading.Tasks;
 
namespace Syntax43
{
    public class App
    {
        public App()
        {
            var game1 = new Game("게임 관리자");
 
            var resource1 = new Resource("금광");
            var unit1 = new Unit("광부");
            unit1.VeinMine(resource1);
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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

11일차 클래스(18)  (0) 2019.10.04
11일차 클래스(17)  (0) 2019.10.04
11일차 클래스(15)  (0) 2019.10.04
11일차 클래스(14)  (0) 2019.10.04
11일차 클래스(13)  (0) 2019.10.04
: