11일차 클래스(9)

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

노트북 상점

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

이름: 삼성

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

노트북을 만든다

 

노트북

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

이름: 노트북 Pen

이름: 노트북 9

이름: 노트북 오디세이

 

요구사항

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

기본 생성자 ( )

 

 
Laptop.cs
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax36
{
    public class Laptop
    {
        //data
        //name
        public string name;
        public Laptop()
        {
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 
LaptopShop.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 Syntax36
{
    public class LaptopShop
    {
        //data
        //name
        public string name;
        public LaptopShop()
        {
 
        }
        public Laptop MakeLaptop(string name)
        {
            var laptop = new Laptop();
            laptop.name = name;
 
            return laptop;
        }
    }
}
 
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
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax36
{
    public class App
    {
        public App()
        {
            var laptopShop1 = new LaptopShop();
            laptopShop1.name = "삼성";
            Console.WriteLine($"{laptopShop1.name}이(가) 만들어졌습니다.");
 
            var laptop1 = laptopShop1.MakeLaptop("노트북 Pen");
            var laptop2 = laptopShop1.MakeLaptop("노트북 9");
            var laptop3 = laptopShop1.MakeLaptop("노트북 오디세이");
 
            Console.WriteLine($"{laptop1.name}이(가) 만들어졌습니다.");
            Console.WriteLine($"{laptop2.name}이(가) 만들어졌습니다.");
            Console.WriteLine($"{laptop3.name}이(가) 만들어졌습니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

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

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