C#/수업 과제
클래스/메서드 과제1
HSH12345
2023. 1. 5. 21:24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _230105
{
class App
{
public App()
{
HighTemplar highTemplar = new HighTemplar("하이템플러1", 40, 40, 0, 100);
highTemplar.PsionicStorm();
highTemplar.PsionicStorm();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _230105
{
class HighTemplar
{
string name;
int hp;
int maxHp;
int shield;
int maxShield;
int energy;
int maxEnergy = 200;
int dmg;
public HighTemplar(string name, int maxHp, int maxShield, int dmg, int energy)
{
this.name = name;
this.maxHp = maxHp;
this.hp = this.maxHp;
this.maxShield = maxShield;
this.shield = this.maxShield;
this.energy = energy;
Console.WriteLine("{0}가 생성되었습니다. HP : {1}/{2} 실드 : {3}/{4}", this.name, this.hp, this.maxHp, this.shield, this.maxShield);
}
public void PsionicStorm()
{
if(this.energy > 75)
{
this.energy = this.energy - 75;
PsionicStorm psionicStorm = new PsionicStorm();
}
else
{
Console.WriteLine("마나가 부족합니다");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _230105
{
class PsionicStorm
{
public PsionicStorm()
{
Console.WriteLine("사이오닉 스톰을 사용합니다");
}
}
}