11일차 클래스(23)

Console Programming/C# Console 2019. 10. 4. 15:05
 
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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax50
{
    public class Burger
    {
        //data
        //name
        public string name;
        public Burger(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}가 생성되었습니다.");
 
            Console.WriteLine($"버거의 이름은 {this.name} 입니다.");
 
        }
    }
}
 
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
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax50
{
    public class Drink
    {
        //data
        //name
        public string name;
        public Drink(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}가 생성되었습니다.");
            Console.WriteLine($"음료의 이름은 {this.name} 입니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
SideDish.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 Syntax50
{
    public class SideDish
    {
        //data
        //name
        public string name;
        public SideDish(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}가 생성되었습니다.");
            Console.WriteLine($"사이드메뉴의 이름은 {this.name} 입니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
ValueMeal.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax50
{
    public class ValueMeal
    {
        //data
        //name
        //burger
        //drink
        //sidedish
        public string name;
        public Burger burger;
        public Drink drink;
        public SideDish sideDish;
 
        public ValueMeal(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}세트 이(가) 생성되었습니다.");
 
        }
        //function
        //GetBurger
        //GetDrink
        //GetSideDish
        //ShowComponent
        public void GetBurger()
        {
            var burger = new Burger(this.name);
            this.burger = burger;
        }
        public void GetDrink(string name)
        {
            var drink = new Drink(name);
            this.drink = drink;
        }
        public void GetSideDish(string name)
        {
            var sideDish = new SideDish(name);
            this.sideDish = sideDish;
        }
        public void ShowComponent()
        {
            Console.WriteLine($"{this.name}의 구성품은");
            Console.WriteLine($"{burger.name}, {drink.name}, {sideDish.name} 입니다.");
 
        }
 
    }
}
 
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 Syntax50
{
    public class App
    {
        public App()
        {
            var valueMeal1 = new ValueMeal("더블 치즈버거");
 
            valueMeal1.GetBurger();
            valueMeal1.GetDrink("콜라");
            valueMeal1.GetSideDish("감자칩");
            valueMeal1.ShowComponent();
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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

백준 11809 알파벳 찾기  (0) 2019.10.08
10.03 11일차 클래스 (29) 질럿,드라군 공격사거리  (0) 2019.10.08
11일차 클래스(22)  (0) 2019.10.04
11일차 클래스(21)  (0) 2019.10.04
11일차 클래스(20)  (0) 2019.10.04
: