수업 007 (04.13 2020) Hatchery, Lava, Drone
2020. 4. 13. 18:26
728x90
1. Class 'App'
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;
namespace Study._8_4
{
class App
{
public App()
{
Hatchery hatchery = new Hatchery(); // (1)
Larva larva = hatchery.CreateLarva(); // (2) : return된 값을 저장할 변수가 필요함
Drone drone = larva.HatchDrone();
larva = null;
Console.WriteLine("hatchery: {0}", hatchery);
Console.WriteLine("larva: {0}", larva);
Console.WriteLine("drone: {0}", drone);
}
}
}
|
2. Class 'Hatchery'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study._8_4
{
class Hatchery
{
public Hatchery()
{
Console.WriteLine("해처리가 생성되었습니다."); // (1)
}
public Larva CreateLarva() // (2)
{
Larva larva = new Larva();
return larva; // (3)
}
}
}
|
3. Class 'Lava'
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 Study._8_4
{
class Larva
{
public Larva()
{
Console.WriteLine("라바가 생성되었습니다."); // (1)
}
// 기능
public Drone HatchDrone() // 변태 // (2)
{
Drone drone = new Drone();
Console.WriteLine("라바가 드론으로 변태 되었습니다.");
Console.WriteLine(drone);
return drone; // (3)
}
}
}
|
4. Class 'Drone'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study._8_4
{
class Drone
{
public Drone()
{
Console.WriteLine("드론이 생성되었습니다."); // (1)
}
}
}
|
728x90
'C# > Study' 카테고리의 다른 글
수업 008 (04.14 2020) Array - Inventory (0) | 2020.04.14 |
---|---|
수업 008 (04.14 2020) (0) | 2020.04.14 |
수업 007 (04.13 2020) TankMode/SeizeMode (0) | 2020.04.13 |
수업 007 (04.13 2020) Barracks (enum, id, unit type, return) (0) | 2020.04.13 |
수업 007 (04.13 2020) Hong vs Lim Again (0) | 2020.04.13 |