10.02 커피상점

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

예제:

커피상점을 만들어 그 커피상점은 커피, 슬리브, 빨대를 만든다.

커피상점이 만든 커피, 슬리브, 빨대를 손님에게 준다.

주는 기능은 커피상점이 갖고있다.

예제:

코드:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System;
namespace _10._02_lvl3_CoffeShop
{
    class App
    {
        public App()
        {
            CoffeeShop coffeeShop = new CoffeeShop("스타벅스");
            Coffee coffee1 = coffeeShop.GetCoffee("아메리카노");
            sleeve sleeve1 = coffeeShop.Getsleeve("LONDON 로고 슬리프");
            straw straw1 = coffeeShop.Getstraw("친환경 종이 빨대");
        }
    }
}
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
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
 
namespace _10._02_lvl3_CoffeShop
{
    class CoffeeShop
    {
        public string name;       
        public CoffeeShop(string name)
        {
            this.name = name;
            Console.WriteLine(this.name + "이(가) 생성되었습니다.");
        }
        public Coffee GetCoffee(string coffee)
        {
            Coffee coffee1 = new Coffee(coffee);
            return coffee1;
        }
        public sleeve Getsleeve(string sleeve)
        {
            sleeve sleeve1 = new sleeve(sleeve);
            return sleeve1;
 
        }
        public straw Getstraw(string straw)
        {
            straw straw1 = new straw(straw);
            return straw1;
 
        }
        public void Give(Coffee coffee, sleeve sleeve, straw straw)
        {
            Console.WriteLine($"{coffee.name}에 {sleeve.name}(을)를 껴서 {straw.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
    class Coffee
    {
        public string name;
        public Coffee(string name)
        {
            this.name = name;
            Console.WriteLine(this.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
class sleeve
    {
        public string name;
        public sleeve(string name)
        {
            this.name = name;
            Console.WriteLine(this.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
class straw
    {
        public string name;
        public straw(string name)
        {
            this.name = name;
            Console.WriteLine(this.name + "이(가) 생성되었습니다.");
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
: