App.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
class App
{
public App()
{
Console.WriteLine("2020-09-25\n");
Mutalisk mutalisk = new Mutalisk();
mutalisk.Transformated();
mutalisk = null;
Trainer trainer = new Trainer();
PocketBall pocketBall = new PocketBall();
trainer.GetBall();
trainer.ThrowBall();
pocketBall = null;
}
}
}
Guardian.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
public class Guardian
{
public Guardian()
{
Console.WriteLine("가디언이 생성됩니다.\n");
}
}
}
Mutalisk.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
public class Mutalisk
{
public Mutalisk()
{
Console.WriteLine("뮤탈리스크가 생성됩니다.");
Console.WriteLine("==================================");
}
public Guardian Transformated()
{
Console.WriteLine("뮤탈리스크가 가디언으로 변태중입니다.");
Console.WriteLine("==================================");
return new Guardian();
}
}
}
PocketBall.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
public class PocketBall
{
public PocketBall()
{
Console.WriteLine("포켓볼이 생성되었습니다.\n");
}
}
}
Pocketmon.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
public class Pocketmon
{
public string name;
public Pocketmon(string name)
{
this.name = name;
Console.WriteLine("포켓몬스터({0})가 생성되었습니다.\n", this.name);
Attack();
}
public void Attack()
{
Console.WriteLine("{0}가 공격을 합니다.\n", this.name);
Console.WriteLine("==================================");
}
}
}
Trainer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
public class Trainer
{
public PocketBall hasball;
public string name;
public Trainer(string name)
{
Console.WriteLine("==================================");
Console.WriteLine("{0}가 생성되었습니다.\n", this.name);
}
public void GetBall(PocketBall hasball)
{
this.hasball = hasball;
Console.WriteLine("지우는 {0}개의 포켓볼을 획득했습니다.\n" ,this.hasball);
Console.WriteLine("지우는 {0}개의 포켓볼을 가지고있습니다.\n", this.hasball);
}
public Pocketmon ThrowBall(PocketBall hasball)
{
Console.WriteLine("지우가 포켓볼{0}개를 던졌습니다.\n", this.hasball);
Console.WriteLine("포켓볼이 터졌습니다.\n");
return new Pocketmon("피카츄");
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study04
{
class Program
{
static void Main(string[] args)
{
new App();
}
}
}
결과화면
'C# > 수업내용' 카테고리의 다른 글
2020.09.29 수업내용 (0) | 2020.09.29 |
---|---|
2020.09.28 상속 & 열거형 예제 (0) | 2020.09.28 |
2020.09.25 수업내용 (0) | 2020.09.25 |
2020-09-25 Instance관련 예제4 (0) | 2020.09.25 |
2020-09-25 Instance관련 예제3 (0) | 2020.09.25 |