class Program
{
static void Main(string[] args)
{
Son s=new Son("盖",9.9,"A","伦");
Daughter d = new Daughter("皎月", 9.99, "O","女神");
Console.WriteLine("盖伦在玩游戏:");
s.Print();
s.PlayGame();
Console.WriteLine("皎月女神在跳舞:");
d.Print();
d.Dance();
Console.ReadKey();
}
}
class Father
{
public Father() { }
public Father(string firstName, double wealth, string blood)
{
this.firstName = firstName;
this.wealth = wealth;
this.blood = blood;
}
string firstName;
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
double wealth;
public double Wealth
{
get { return wealth; }
set { wealth = value; }
}
string blood;
public string Blood
{
get { return blood; }
set { blood = value; }
}
public void PlayGame()
{
Console.WriteLine("我姓{0},我的财富是{1},我的血型是{2},我在玩游戏!", firstName, wealth, blood);
}
public void Dance()
{
Console.WriteLine("我姓{0},我的财富是{1},我的血型是{2},我在跳舞!", firstName, wealth, blood);
}
}
class Son : Father
{
public Son() { }
public Son(string firstName,double wealth,string blood,string name)
:base(firstName, wealth, blood)
{
this.name = name;
}
string name;
public string Name
{
get { return name; }
set { name = value; }
}
public void Print()
{
Console.WriteLine("我的名字是{0}", name);
}
}
class Daughter : Father
{
public Daughter() { }
public Daughter(string firstName,double wealth,string blood,string name)
:base(firstName, wealth, blood)
{
this.name = name;
}
string name;
public string Name
{
get { return name; }
set { name = value; }
}
public void Print()
{
Console.WriteLine("我的名字是{0}", name);
}
} |