11일차 클래스(21)

Console Programming/C# Console 2019. 10. 4. 15:00
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 Syntax48
{
    public class Engine
    {
 
        //data
        //name
        public string name;
        public Engine(string name)
        {
            this.name = name;
            Console.WriteLine($"엔진 ({this.name})이(가) 생성되었습니다.");
            Console.WriteLine($"엔진의 이름은 {this.name} 엔진 입니다.");
        }
 
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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 Syntax48
{
    public class Tire
    {
        //data
        //name
        public string brand;
        public string productName="Solus TA31";
        public Tire(string brand)
        {
            this.brand = brand;
            Console.WriteLine($"타이어 ({this.brand})이(가) 생성되었습니다.");
            Console.WriteLine($"타이어의 이름은 {this.brand} 입니다.");
            Console.WriteLine($"{this.brand}의 규격은 {this.productName}입니다.");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax48
{
    public class Car
    {
        //data
        //name
        //engine
        //tire
        public string name;
        public Engine engine;
        public Tire tire;
 
        public Car(string name)
        {
            this.name = name;
            Console.WriteLine($"{this.name}이 생성되었습니다.");
        }
        public void GetEngine(string name)
        {
            var engine = new Engine(name);
            this.engine = engine;
        }
        public void GetTire(string name)
        {
            var tire = new Tire(name);
            this.tire = tire;
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

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 Syntax48
{
    public class App
    {
        public App()
        {
            var car1 = new Car("KIA 모닝");
 
            car1.GetEngine("카파 1.0 ECO Prine");
            car1.GetTire("Kumho타이어");
 
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 

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

11일차 클래스(23)  (0) 2019.10.04
11일차 클래스(22)  (0) 2019.10.04
11일차 클래스(20)  (0) 2019.10.04
11일차 클래스(19)  (0) 2019.10.04
11일차 클래스(18)  (0) 2019.10.04
: