11일차 클래스(3)

Console Programming/C# Console 2019. 10. 4. 14:20

빵집

------------------

이름: 파리바게트

------------------

빵을 만든다

 

------------------

이름: 소보루빵

이름: 우유식빵

이름: 단팥빵

 

요구사항

------------------

기본 생성자 메서드

 

 
Bread.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 Syntax30
{
    public class Bread
    {
        //데이터
        //이름
        public string name;
            
        public Bread()
        {
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
Bakery.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 Syntax30
{
    public class Bakery
    {
        //데이터
        //이름
        public string name;
 
        public Bakery()
        {
 
        }
 
        public Bread MakeBread(string name)
        {
            Bread bread = new Bread();
            bread.name = name;
            return bread;
        }
    }
}
 
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
28
29
30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax30
{
    public class App
    {
        public App()
        {
            var bakery1 = new Bakery();
            bakery1.name = "파리바게트";
            Console.WriteLine($"{bakery1.name}이(가) 만들어졌습니다.");
 
            var bread1 = bakery1.MakeBread("소보루빵");
            
            var bread2 = bakery1.MakeBread("우유식빵");
           
            var bread3 = bakery1.MakeBread("단팥빵");
           
            Console.WriteLine($"{bread1.name}이(가) 만들어졌습니다.");
            Console.WriteLine($"{bread2.name}이(가) 만들어졌습니다.");
            Console.WriteLine($"{bread3.name}이(가) 만들어졌습니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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

11일차 클래스(5)  (0) 2019.10.04
11일차 클래스(4)  (0) 2019.10.04
11일차 클래스(2)  (0) 2019.10.04
11일차 클래스 피자상점  (0) 2019.10.04
10일차 클래스(2) 버거상점, 세트메뉴  (0) 2019.10.04
: