11일차 클래스(5)
Console Programming/C# Console 2019. 10. 4. 14:25자동차 공장
------------------
이름: 현대
------------------
자동차를 만든다
자동차
------------------
이름: 투산
이름: 엑센트
이름: 코나
요구사항
------------------
기본 생성자 메서드
|
Car.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;
namespace Syntax31
{
public class Car
{
//데이터
//이름
public string name;
public Car()
{
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
s |
|
CarFactory.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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax31
{
public class CarFactory
{
//데이터
//이름
public string name;
public CarFactory()
{
}
public Car MakeCar(string name)
{
var car = new Car();
car.name = name;
return car;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
cs |
|
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
29
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax31
{
public class App
{
public App()
{
var carfactory1 = new CarFactory();
var car1 = carfactory1.MakeCar("투싼");
var car2 = carfactory1.MakeCar("엑센트");
var car3 = carfactory1.MakeCar("코나");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
cs |
'Console Programming > C# Console' 카테고리의 다른 글
11일차 클래스(7) (0) | 2019.10.04 |
---|---|
11일차 클래스(6) (0) | 2019.10.04 |
11일차 클래스(4) (0) | 2019.10.04 |
11일차 클래스(3) (0) | 2019.10.04 |
11일차 클래스(2) (0) | 2019.10.04 |