10.02 컴퓨터 조립

C#/실습 2019. 10. 2. 17:36

에제:

코드:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
class App
    {
        public App()
        {
            GraphicCard graphicCard1 = new GraphicCard("GT730","GAINWARD");
            CPU cpu1 = new CPU("라이젠 3""AMD");
            PC pc1 = new PC("컴퓨터1", cpu1, graphicCard1);
            pc1.ReadCPU();
            pc1.ReadGraPhicCard();
            cpu1.ReadManu();
            graphicCard1.ReadManu();
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 class PC
    {
        public string name;
        CPU cpu;
        GraphicCard graphicCard;
        public PC(string name, CPU cpu, GraphicCard graphicCard)
        {
            this.name = name;
            this.cpu = cpu;
            this.graphicCard = graphicCard;
            Console.WriteLine(this.name + "이(가) 생성되었습니다.");
            Console.WriteLine(this.name + "의 그래픽카드가 생성되었습니다.");
            Console.WriteLine(this.name + "의 CPU가 생성되었습니다.");
 
        }
        public void ReadCPU()
        {
            Console.WriteLine($"{this.name}의 CPU는 {this.cpu.name}입니다.");
        }
        public void ReadGraPhicCard()
        {
            Console.WriteLine($"{this.name}의 그래픽카드는 {this.graphicCard.name}입니다.");
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class CPU
    {
        public string name;
        public string manufacturer;
        public CPU(string name, string manu)
        {
            this.name = name;
            this.manufacturer = manu;
 
        }
        public void ReadManu()
        {
            Console.WriteLine($"{this.name}의 제조사는 {this.manufacturer}입니다.");
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 class GraphicCard
    {
        public string name;
        public string manufacturer;
        public GraphicCard(string name, string manuname)
        {
            this.name = name;
            this.manufacturer = manuname;            
        }
        public void ReadManu()
        {
            Console.WriteLine($"{this.name}의 제조사는 {this.manufacturer}입니다.");
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

'C# > 실습' 카테고리의 다른 글

10.07 Class 활용해 BurgerSet 만들기  (0) 2019.10.07
10.07 class 활용해 자동차만들기  (0) 2019.10.07
10.02 자동차 부품설정  (0) 2019.10.02
10.02 버거세트  (0) 2019.10.02
10.02 커피상점  (0) 2019.10.02
: