11일차 클래스 피자상점

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

피자상점

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

이름: 피자알볼로

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

피자를 만든다

 

 

피자

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

이름: 전주불백피자

이름: 부산피자

이름: 단호박피자

 

 

요구사항

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

생성자 메서드 (매개변수)

 

 
Pizza.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax28
{
 
 
 
    
    public class Pizza
    {
        public string name;
        //생성자 메서드 또는 생성자 라고부른다
        public Pizza(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 만들어졌습니다.");
          
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
PizzaShop.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax28
{
 
 
   
    public class PizzaShop
    {
 
        public string name;
 
        //생성자 메서드 또는 생성자 라고부른다
        public PizzaShop(string name)
        {
            this.name = name;
        }
 
        public Pizza MakePizza(string name)
        {
            Pizza pizza = new Pizza(name);
            
            return pizza;
        }
 
    }
}
 
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
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax28
{
    public class App
    {
        public App()
        {
            PizzaShop pizzashop1 = new PizzaShop("PiaazAlvolo");
 
 
            Pizza pizza1 = pizzashop1.MakePizza("전주불백피자");
            Pizza pizza2 = pizzashop1.MakePizza("부산피자");
            Pizza pizza3 = pizzashop1.MakePizza("단호박피자");
 
           
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

: