11일차 클래스(6)

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

아이스크림 상점

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

이름: 베스킨라벤스

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

아이스크림을 만든다

 

아이스크림

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

이름: 딸바봉

이름: 쌀떡궁합

이름: 민트초코

 

생성자 메서드 (매개변수)

 

 
Icecream.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 Syntax33
{
    public class Icecream
    {
        //data
        //name
        public string name;
 
        public Icecream(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
 

 

 
IcecreamShop.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 Syntax33
{
    public class IcecreamShop
    {
        //데이터
        //이름
        public string name;
        public IcecreamShop(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 만들어졌습니다.");
        }
        public Icecream MakeIcecream(string name)
        {
            var icecream = new Icecream(name);
           
            return icecream;
        }
    }
}
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax33
{
    public class App
    {
        public App()
        {
            var icecreamShop1 = new IcecreamShop("베스킨라벤스");
 
            var icecream1 = new Icecream("딸바봉");
            var icecream2 = new Icecream("쌀떡궁합");
            var icecream3 = new Icecream("민트초코");
 
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

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

11일차 클래스(8)  (0) 2019.10.04
11일차 클래스(7)  (0) 2019.10.04
11일차 클래스(5)  (0) 2019.10.04
11일차 클래스(4)  (0) 2019.10.04
11일차 클래스(3)  (0) 2019.10.04
: