Egg.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace HomeWork01
{
public class Egg
{
public Egg()
{
Console.WriteLine("알이 생성되었습니다.");
Console.WriteLine("================================");
}
public void Destroy(Egg target)
{
Console.WriteLine("{0}이 깨집니다.", target);
Console.WriteLine("================================");
target = null;
}
}
}
Hatchery.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace HomeWork01
{
public class Hatchery
{
public Egg egg;
public Hatchery()
{
Console.WriteLine("해처리 생성 완료!");
}
public Scourge[] CreateUnit(Egg egg)
{
this.egg = egg;
Console.WriteLine("{0}이 유닛을 부화중입니다.", egg);
Console.WriteLine("================================");
egg.Destroy(egg);
Scourge[] scourges = new Scourge[2];
for (int i = 0; i < scourges.Length; i++)
{
scourges[i] = new Scourge();
}
return scourges;
}
}
}
Scourge.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HomeWork01
{
public class Scourge
{
public Scourge()
{
Console.WriteLine("스커지가 생성됩니다.");
}
}
}
App.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace HomeWork01
{
public class App
{
public App()
{
Hatchery hatchery = new Hatchery();
Egg egg = new Egg();
hatchery.CreateUnit(egg);
}
}
}
'C# > 과제' 카테고리의 다른 글
2020.10.05 과제 (0) | 2020.10.05 |
---|---|
2020.09.29 과제 (0) | 2020.10.03 |
2020.09.25 주말과제 (0) | 2020.09.25 |
2020.09.24 과제 (0) | 2020.09.24 |
2020.09.23 과제 (0) | 2020.09.23 |