10일차 클래스(2) 버거상점, 세트메뉴

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

버거상점

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

이름:맥도날드

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

버거를만든다

음료를만든다

감자칩을만든다

버거세트를만든다

 

버거

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

이름:1955버거

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

 

음료

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

이름:콜라

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

 

감자칩

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

이름:감자칩

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

 

버거세트

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

이름:1955세트

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

버거를만든다

음료를만든다

감자칩을만든다

 

 

 
Burger.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
using System;
using System.Collections.Generic;
 
namespace Syntax27
{
    
    public class Burger
    {
        //데이터
        //이름
        public string name;
        
        public Burger()
        {
 
        }
        //기능
    }
}
    
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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

 

 
FrenchFries.cs
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
 
namespace Syntax27
{
    public class FrenchFries
    {
        //데이터
        //이름
        //크기
        public string name;
        public FrenchFries()
        {
 
        }
 
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
ValueMeals.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
using System;
using System.Collections.Generic;
 
 
namespace Syntax27
{
    public class ValueMeals
    {
        //데이터
        //이름
        public string name;
        public Burger burger;
        public Drink drink;
        public FrenchFries frenchfries;
 
        public ValueMeals()
        {
            burger = new Burger();
            drink = new Drink();
            frenchfries = new FrenchFries();
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 버거세트를 호출하면 새로운 버거, 음료, 감자칩이 만들어지도록 했다.

버거세트에는 Burger, Drink, FrenchFries 타입의 변수가 각각 데이터로 들어가있다.

 

 

 
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
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax27
{
    public class App
    {
        public BurgerShop burgershop1;
        public App()
        {
            BurgerShop burgershop1 = new BurgerShop();
            burgershop1.name = "McDonalds";
            Console.WriteLine(burgershop1.name + "가 만들어졌습니다.");
 
            ValueMeals valuemeal1 = burgershop1.MakeValueMeal();
 
            valuemeal1.burger.name = "1955버거";
            valuemeal1.drink.name = "콜라";
            valuemeal1.frenchfries.name = "감자튀김";
 
            Console.WriteLine($"{valuemeal1.burger.name}가 만들어졌습니다.");
            Console.WriteLine($"{valuemeal1.drink.name}가 만들어졌습니다.");
            Console.WriteLine($"{valuemeal1.frenchfries.name}가 만들어졌습니다.");
 
 
 
 
 
        }
 
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 

 

 

: