Now that we've started learning object-oriented 3 days, I've found that object-oriented is well-wound;
eg:public int Baoji
{
Get
{
return Baoji;
}
Set
{
Baoji = value;
if (Baoji < 0)
{
Baoji = 0;
}
if (Baoji > 100)
{
Baoji = 100;
}
}
}
public void Attackmonster (monster m)
{console.foregroundcolor = Consolecolor.magenta;
Random rad = new Random ();//Stochastic number
int num = rad. Next (1, 101);//Random values
Check if you are dodging
if (num <= m.shanbi)
{
Console.WriteLine ("Sorry!! The attack is ineffective, and the clever beast easily dodges your attack ");
Return
}
int Shanhai = Attack-m.deface;
Shanhai = Shanhai < 1? 1:shanhai;
Check if critical hit
num = rad. Next (1, 101);
if (num <= Baoji)
{
Shanhai *= 2;
Console.Write ("Critical hit! ");
}
M.shengmingli-= Shanhai;
Console.WriteLine ("Hero fierce attack the monster, so that the monster by {0} point damage, monsters remaining vitality: {1}", Shanhai, M.shengmingli);
}
Wait a minute
. NET second week's learning situation