/*
编写一个存储艺术作品的程序。艺术作品分为三类:Painting、Music和Chamber,Chamber是Music中的一类。
要求如下所述。每件作品都要标明著者、作品标题、作品诞生年份及其所属分类。
Painting类要求显示画的宽和高等尺寸信息。
Music类要求显示能够代表其内容的关键信息
Chamber类要求显示其中包括的演奏人员的数目
*/
#include<iostream>
using namespace std;
class Art
{
public://ctor&dtor
Art()
{
}
Art(string uiAuthor,string uiTitle,string uiYear,string uiClasses)
{
m_uiAuthor=uiAuthor;
m_uiTitle=uiTitle;
m_uiYear=uiYear;
m_uiClasses=uiClasses;
}
public://interface
void Disp()const
{
cout<<"著者:"<< m_uiAuthor<<endl;
cout<<"作品标题:"<< m_uiTitle<<endl;
cout<<"作品诞生年份:"<<m_uiYear<<endl;
cout<<"所属分类:"<<m_uiClasses<<endl;
}
private:
protected:
string m_uiAuthor;
string m_uiTitle;
string m_uiYear;
string m_uiClasses;
};
class Painting : public Art
{
public://ctor&dtor
Painting():Art()
{
m_uiWight=0.0f;
m_uiHigh=0.0f;
}
Painting(string uiAuthor,string uiTitle,string uiYear,string uiClasses,float uiWight,float uiHigh)
:Art(uiAuthor,uiTitle,uiYear,uiClasses)
{
m_uiWight=uiWight;
m_uiHigh=uiHigh;
}
public://interface
void Disp()const
{
Art::Disp();
cout<<"画的宽:"<<m_uiWight<<endl;
cout<<"画的高:"<<m_uiHigh<<endl;
}
private:
float m_uiWight;
float m_uiHigh;
protected:
};
class Music : public Art
{
public://ctor&dtor
Music():Art()
{
}
Music(string uiAuthor,string uiTitle,string uiYear,string uiClasses,string uiKeywords)
:Art(uiAuthor,uiTitle,uiYear,uiClasses)
{
m_uiKeywords=uiKeywords;
}
public://interface
void Disp()const
{
Art::Disp();
cout<<"关键信息:"<<m_uiKeywords<<endl;
}
private:
protected:
string m_uiKeywords;
};
class Chamber : public Music
{
public://ctor&dtor
Chamber():Music()
{
m_uiNumber=0;
}
Chamber(string uiAuthor,string uiTitle,string uiYear,string uiClasses,string uiKeywords,unsigned int uiNumber)
:Music(uiAuthor,uiTitle,uiYear,uiClasses,uiKeywords)
{
m_uiNumber=uiNumber;
}
public://interface
void Disp()const
{
Music::Disp();
cout<<"演奏人员:"<<m_uiNumber<<endl;
}
private:
unsigned int m_uiNumber;
protected:
};
int main(int argc,char *argv[])
{
cout<<"............Art类............"<<endl;
Art art("达芬奇","最后的晚餐","1494年~1498年","油画");
art.Disp();
cout<<"..........Painting类........."<<endl;
Painting painting("达芬奇","最后的晚餐","1494年~1498年","油画",910.0f,420.0f);
painting.Disp();
cout<<"...........Music类..........."<<endl;
Music music("达芬奇","最后的晚餐","1494年~1498年","油画","达·芬奇不仅在绘画技艺上力求创新,在画面的布局上也别具新意。一直以来,画面布局都是耶稣弟子们坐成一排,耶稣独坐一端。达·芬奇却让十二门徒分坐于耶稣两边,耶稣孤寂地坐在中间,他的脸被身后明亮的窗户映照,显得庄严肃穆。背景强烈的对比让人们把所有的注意力全部集中于耶稣身上。耶稣旁边那些躁动的弟子们,每个人的面部表情、眼神、动作各不相同。尤其是慌乱的犹大,手肘碰倒了盐瓶,身体后仰,满脸的惊恐与不安。");
music.Disp();
cout<<"..........Chamber类.........."<<endl;
Chamber chamber("达芬奇","最后的晚餐","1494年~1498年","油画","达·芬奇不仅在绘画技艺上力求创新,在画面的布局上也别具新意。一直以来,画面布局都是耶稣弟子们坐成一排,耶稣独坐一端。达·芬奇却让十二门徒分坐于耶稣两边,耶稣孤寂地坐在中间,他的脸被身后明亮的窗户映照,显得庄严肃穆。背景强烈的对比让人们把所有的注意力全部集中于耶稣身上。耶稣旁边那些躁动的弟子们,每个人的面部表情、眼神、动作各不相同。尤其是慌乱的犹大,手肘碰倒了盐瓶,身体后仰,满脸的惊恐与不安。",12);
chamber.Disp();
}