10.07 class 활용해 1955버거 만들기

C#/실습 2019. 10. 7. 17:04

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class App
    {
        public App()
        {
            Patty patty = new Patty();
            patty.SetPatty("순쇠고기패티");
            Lettuce lettuce = new Lettuce();
            lettuce.SetLettuce("신선함");
            Cheeze cheeze = new Cheeze();
            cheeze.SetCheeze("모짜렐라");
            Burger burger = new Burger();
            burger.SetBurger(patty, lettuce, cheeze);
            var P = burger.GetPatty();
            var L = burger.GetLettuce();
            var C = burger.GetCheeze();
            Console.WriteLine($"1955버거의 구성품은 {P},{L},{C}입니다.");
        }
    }
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
class Burger
    {
        Patty patty;
        Lettuce lettuce;
        Cheeze cheeze;
        public Burger()
        {
 
        }
        public void SetBurger(Patty patty, Lettuce lettuce, Cheeze cheeze)
        {
            this.patty = patty;
            this.lettuce = lettuce;
            this.cheeze = cheeze;
        }
        public string GetPatty()
        {
            return this.patty.GetPatty();
        }
        public string GetLettuce()
        {
            return this.lettuce.GetLettuce();
        }
        public string GetCheeze()
        {
            return this.cheeze.GetCheeze();
        }
        
    }
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
class Patty
    {
        string name;
        public Patty()
        {
 
        }
        public void SetPatty(string name)
        {
            this.name = name;
        }
        public string GetPatty()
        {
            return 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
12
13
14
15
16
class Lettuce
    {
        string name;
        public Lettuce()
        {
 
        }
        public void SetLettuce(string name)
        {
            this.name = name;
        }
        public string GetLettuce()
        {
            return 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
12
13
14
15
16
class Cheeze
    {
        string name;
        public Cheeze()
        {
 
        }
        public void SetCheeze(string name)
        {
            this.name = name;
        }
        public string GetCheeze()
        {
            return this.name;
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
: