11일차 클래스(22)

Console Programming/C# Console 2019. 10. 4. 15:02
 
CPU.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax49
{
    public class CPU
    {
        //data
        //name
        //manufacturer
        public string name;
        public string manufacturer="AMD";
 
        public CPU(string name,PC pcname)
        {
            this.name = name;
            Console.WriteLine($"{pcname.name}의 CPU가 생성되었습니다.");
            Console.WriteLine($"{pcname.name}의 CPU의 이름은 {this.name} 입니다.");
            Console.WriteLine($"{this.name}의 제조사는 {this.manufacturer}입니다.");
 
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
GraphicCard.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax49
{
    public class GraphicCard
    {
        //data
        //name
        //manufacturer
        public string name;
        public string manufacturer="GAINWARD";
        public GraphicCard(string name, PC pcname)
        {
            this.name = name;
            Console.WriteLine($"{pcname.name}의 그래픽 카드가 생성되었습니다.");
            Console.WriteLine($"{pcname.name}의 그래픽 카드의 이름은 {this.name} 입니다.");
            Console.WriteLine($"{this.name}의 제조사는 {this.manufacturer}입니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
PC.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax49
{
    public class PC
    {
        //data
        //name
        //GraphicCard
        //CPU
        public string name;
        public GraphicCard graphicCard;
        public CPU cpu;
        public PC(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 생성되었습니다.");
 
        }
        //function
        //GetGraphicCard
        //GetCPU
        public void GetGraphicCard(string name)
        {
            var graphicCard = new GraphicCard(name, this);
            this.graphicCard = graphicCard;            
        }
        public void GetCPU(string name)
        {
            var cpu = new CPU(name, this);
            this.cpu = cpu;
        }
 
    }
}
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax49
{
    public class App
    {
        public App()
        {
            var pc1 = new PC("PC");
 
            pc1.GetGraphicCard("GT730");
            pc1.GetCPU("라이젠 3");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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

10.03 11일차 클래스 (29) 질럿,드라군 공격사거리  (0) 2019.10.08
11일차 클래스(23)  (0) 2019.10.04
11일차 클래스(21)  (0) 2019.10.04
11일차 클래스(20)  (0) 2019.10.04
11일차 클래스(19)  (0) 2019.10.04
: