class Student1 : public Student
{
public:
Student1(int n, string nam, char s, int a, string addr) : Student(n, nam, s)
{
age = a;
address = addr;
}
void show()
{
cout << "num: " << num << endl;
cout << "name: " << name << endl;
cout << "sex: " << sex << endl;
cout << "age: " << age << endl;
cout << "address: " << address << endl<<endl;
}
private:
int age;
string address;
};
class RobotB : public RobotA{
public:
RobotB(string _name, string _skill) : RobotA(_name)
{
skill = _skill;
cout << "RobotB come to the word!" << endl;
}
void Bspeak()
{
cout << "I'm the second generation of robots, the first generation is " << name << "." << endl;
cout << "I can " << skill << "." << endl;
}
~RobotB()
{
cout << "RobotB leaves the word!" << endl;
}
protected:
string skill;
};
class RobotC : public RobotB{
public:
RobotC(string _name, string _skill1, string _skill2) : RobotB(_name, _skill1)
{
skill2 = _skill2;
cout << "RobotC come to the word!" << endl;
}
void Cspeak()
{
cout << "I'm the third generation of robots, the first generation is " << name << "." << endl;
cout << "I can " << skill << ",and " << skill2 << "." << endl;
}
~RobotC()
{
cout << "RobotC leaves the word!" << endl;
}
protected:
string skill2;
};
class TV{
public:
TV(string _brand, int _size)
{
brand = _brand;
size = _size;
cout << "购买电视" << endl;
}
void showt()
{
cout << "这是我的客厅." << endl;
cout << "电视品牌是" << brand << ",屏幕大小是" << size << "寸." << endl;
}
protected:
string brand;
int size;
};
class TDesk{
public:
TDesk(string _shape,string _colour)
{
shape=_shape;
colour=_colour;
cout<<"购买茶几"<<endl;
}
void showd()
{
cout << "茶几是" << shape << "形,颜色是" << colour << "色." << endl;
}
protected:
string shape;
string colour;
};
class Droom : public Room{
public:
Droom(double _area, string _brand, int _size, string _shape, string _colour) : Room(_area), t(_brand, _size), d(_shape, _colour)
{
}
TV t;
TDesk d;
};
class Flower : public Plant
{
private:
string colour;
public:
Flower() : Plant(""), colour("") {}
Flower(string _name,string _colour): Plant(_name),colour(_colour){}
void showf()
{
if (name == "")
cout << "no name ";
else
cout << name << " ";
if (colour == "")
cout << "is no colour." << endl;
else
cout << "is " << colour << "." << endl;
}
};