12일차 클래스(2)
Console Programming/C# Console 2019. 10. 8. 08:48
|
Program.cs
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax02
{
class Program
{
static void Main(string[] args)
{
new App();
}
}
}
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
29
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax02
{
public class App
{
public App()
{
var car1 = new Car("니로");
var engine1 = new Engine("카파 1.6 GDI 엔진");
var tire1 = new Tire("미쉐린 ENERGY SAVER AS");
car1.SetEngine(engine1);
var engineNiro = car1.GetEngine();
car1.SetTire(tire1);
var tireNiro = car1.GetTire();
Console.WriteLine($"{car1.GetCarName()}에 {engineNiro.GetEngineName()}과
{tireNiro.GetTireName()}를 조립했습니다.");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
Car.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax02
{
public class Car
{
//data
//name
//Engine
//Tire
string name;
Engine engine;
Tire tire;
public Car(string name)
{
this.name = name;
}
//function
//SetTire
//Gettire
//SetEngine
//GetEngine
public string GetCarName()
{
return this.name;
}
public void SetTire(Tire tire)
{
this.tire = tire;
}
public Tire GetTire()
{
return tire;
}
public void SetEngine(Engine engine)
{
this.engine = engine;
}
public Engine GetEngine()
{
return engine;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
Engine.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 Syntax02
{
public class Engine
{
//data
//name
string name;
public Engine(string name)
{
this.name = name;
}
public string GetEngineName()
{
return this.name;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
|
Tire.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;
namespace Syntax02
{
public class Tire
{
//data
//name
string name;
public Tire(string name)
{
this.name = name;
}
public string GetTireName()
{
return this.name;
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
'Console Programming > C# Console' 카테고리의 다른 글
12일차 클래스(4) (0) | 2019.10.08 |
---|---|
12일차 클래스(3) (0) | 2019.10.08 |
12일차 클래스 2차원 위치정보 (0) | 2019.10.08 |
백준 2675 문자열 반복 (0) | 2019.10.08 |
백준 2675 문자열 반복 (0) | 2019.10.08 |