time 
设为首页】【收藏本站
当前位置: 主页 > 程序设计 > C\C++\VC > C语言 > 例程实作----庖丁解羊(下)

例程实作----庖丁解羊(下)

时间:2009-09-20 23:31 点击:971次 字体:[ ]




    #include <iostream>

    #include <string>

    using namespace std;

    class Part{

    public:

            virtual void Draw()=0;

            virtual ~Part(){}

    };

    class Shape{

    public:

            Shape( string const& _s ):data( _s ){}

            void Draw( unsigned color )

                    {

                    cout << data << " with color :" << hex << color << endl;

                    } //提供了借口,但是没有实现绘图

    private:

            string data;

            //读者可以自己实现绘图部分

    };

    //绒毛,骨架,胸,腹,背,眼睛,鼻子,嘴巴,心,脾,肝,肠,肾,脚,尾巴,耳朵,肺,胃{{部分,显示=轮廓+颜色},轮廓[1],颜色[1]}

    class BasePart : public Part{

    public:

            BasePart( string const& _s , unsigned _c ):shape( _s ),color( _c ){}

            void Draw()

                    {

                    shape.Draw( color );

                    }

    private:

            Shape shape;

            unsigned color;

    };

    //绒毛

    class Floss : public BasePart{

    public:

            Floss( ):BasePart("Floss " ,0){}

    };

    //骨架

    class Skelecton : public BasePart{

    public:

            Skelecton( ):BasePart("Skelecton " ,0){}

    };

    //胸

    class Bosom : public BasePart{

    public:

            Bosom( ):BasePart("Bosom " ,0){}

    };

    //腹

    class Abdomen : public BasePart{

    public:

            Abdomen ( ):BasePart("Abdomen " ,0){}

    };

    //背

    class Backside: public BasePart{

    public:

            Backside ( ):BasePart("Backside " ,0){}

    };

    //眼睛

    class Eye : public BasePart{

    public:

            Eye ( ):BasePart("Eye " ,0){}

    };

    //耳朵

    class Ear : public BasePart{

    public:

            Ear ( ):BasePart("Ear " ,0){}

    };

    //鼻子

    class Nose : public BasePart{

    public:

            Nose ( ):BasePart("Nose " ,0){}

    };

    //嘴巴

    class Mouth : public BasePart{

    public:

            Mouth ( ):BasePart("Mouth " ,0){}

    };

    //尾巴

    class Stern : public BasePart{

    public:

            Stern ( ):BasePart("Stern " ,0){}

    };

    //胡子

    class Goatee : public BasePart{

    public:

            Goatee ( ):BasePart("Goatee " ,0){}

    };

    //心

    class Heart : public BasePart{

    public:

            Heart ( ):BasePart("Heart " ,0){}

    };

    //脾

    class Spleen : public BasePart{

    public:

            Spleen ( ):BasePart("Spleen " ,0){}

    };

    //肝

    class Liver : public BasePart{

    public:

            Liver ( ):BasePart("Liver " ,0){}

    };

    //肺

    class Lung : public BasePart{

    public:

            Lung ( ):BasePart("Lung " ,0){}

    };

    //胃

    class Stomach : public BasePart{

    public:

            Stomach ( ):BasePart("Stomach " ,0){}

    };

    //肠

    class Intestine : public BasePart{

    public:

            Intestine ( ):BasePart("Intestine " ,0){}

    };

    //肾

    class Kidney : public BasePart{

    public:

            Kidney ( ):BasePart("Kidney " ,0){}

    };

    //脚

    class Leg : public BasePart{

    public:

            Leg ( ):BasePart("Leg " ,0){}

    };

    //肢体{{部分, 显示=显示肢体},脚[1],绒毛[n],骨架[1]}

 



本文地址 : http://www.fengfly.com/plus/view-77274-1.html
标签: 例程实作
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:
本栏分类