10.02 버거세트

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

예제:

코드:

 

1
2
3
4
5
6
7
8
9
10
class App
    {
        public App()
        {
            Burger burger = new Burger("더블치즈버거");
            Drink drink = new Drink("콜라");
            Side side = new Side("감자칩");
            new Set(burger, drink, side);                       
        }
    }
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 Burger
    {
        public string name;
        public Burger(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 Drink
    {
        public string name;
        public Drink(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 Side
    {
        public string name;
        public Side(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
12
13
14
class Set
    {
        Burger burger;
        Drink drink;
        Side side;
        public Set(Burger burger, Drink drink, Side side)
        {
            this.burger = burger;
            this.drink = drink;
            this.side = side;
            Console.WriteLine(this.burger.name + "세트가 생성되었습니다.");
            Console.WriteLine(this.burger.name + "세트의 구성품은 " + this.burger.name + this.drink.name + this.side.name + " 입니다.");
        }
    }
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 
: