11일차 클래스(8)

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

핸드폰 상점

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

이름: Apple

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

핸드폰을 만든다

 

핸드폰

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

이름: iPhone 11Pro

이름: iPhone 11

이름: iPhone Xr

 

요구사항

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

생성자 (매개변수)

 

 
CellPhone.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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax35
{
    public class CellPhone
    {
        //data
        //name
        public string name;
        public CellPhone(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
 

 

 
CellPhoneShop.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax35
{
    public class CellPhoneShop
    {
        //data
        //name
        public string name;
        public CellPhoneShop(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이(가) 만들어졌습니다.");
        }
        public CellPhone MakeCellPhone(string name)
        {
            var cellPhone = new CellPhone(name);
 
            return cellPhone;
        }
    }
}
 
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax35
{
    public class App
    {
        public App()
        {
            var cellPhoneShop1 = new CellPhoneShop("Apple");
 
            var cellPhone1 = cellPhoneShop1.MakeCellPhone("iPhone 11Pro");
            var cellPhone2 = cellPhoneShop1.MakeCellPhone("iPhone 11");
            var cellPhone3 = cellPhoneShop1.MakeCellPhone("iPhone 11 Xr");
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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

11일차 클래스(10)  (0) 2019.10.04
11일차 클래스(9)  (0) 2019.10.04
11일차 클래스(7)  (0) 2019.10.04
11일차 클래스(6)  (0) 2019.10.04
11일차 클래스(5)  (0) 2019.10.04
: