Routine
---- 庖庖 羊 (below)
#include
#include
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;
} // provides an excuse, but does not implement a drawing
Private:
String data;
// reader can implement the drawing part
}
/ =, 眼,, =, =, =, =, =, = = = 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分 部分1], color [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) {}
}
//skeleton
Class Skelectron: Public Basepart {
PUBLIC:
Skelecton (): Basepart ("Skelecton", 0) {}
}
//chest
Class bosom: public basepart {
PUBLIC:
Bosom (): Basepart ("bosom", 0) {}
}
//belly
Class abdomen: public basepart {
PUBLIC:
Abdomen (): Basepart ("Abdomen", 0) {}
}
// back
Class Backside: public basepart {
PUBLIC:
BACKSIDE (): Basepart ("Backside", 0) {}
}
//eye
Class Eye: Public Basepart {
PUBLIC:
Eye (): Basepart ("Eye", 0) {}
}
//ear
Class Ear: public basepart {
PUBLIC:
EAR (): Basepart ("Ear", 0) {}
}
//nose
Class Nose: Public Basepart {
PUBLIC:
Nose (): Basepart ("Nose", 0) {}
}
//mouth
Class mout: public basepart {
PUBLIC:
Mouth (): Basepart ("mouth", 0) {}
}
//tail
Class Stern: Public Basepart {public:
Stern (): Basepart ("Stern", 0) {}
}
//Moustache
Class Goatee: Public Basepart {
PUBLIC:
Goatee (): Basepart ("GoATEE", 0) {}
}
//heart
Class Heart: public basepart {
PUBLIC:
Heart (): Basepart ("Heart", 0) {}
}
//spleen
Class SPLEEN: Public Basepart {
PUBLIC:
Spleen (): Basepart ("spleen", 0) {}
}
//liver
Class Liver: Public Basepart {
PUBLIC:
Liver (): Basepart ("Liver", 0) {}
}
//lung
Class lung: public basepart {
PUBLIC:
Lung (): Basepart ("lung", 0) {}
}
//stomach
Class Stomach: Public Basepart {
PUBLIC:
Stomach (): Basepart ("stomach", 0) {}
}
//intestinal
Class Intestine: public basepart {
PUBLIC:
Intestine (): Basepart ("Intestine", 0) {}
}
//kidney
Class kidney: public basepart {
PUBLIC:
Kidney (): Basepart ("Kidney", 0) {}
}
//foot
Class leg: public basepart {
PUBLIC:
LEG (): Basepart ("leg", 0) {}
}
// limb {{section, display = display limbs}, foot [1], fluff [N], skeleton [1]}
Class Limb: Public Part {
PUBLIC:
Void Draw ()
{
COUT << "HAS A";
Leg.draw ();
COUT << "HAS A";
Skelectron.draw ();
COUT << "HAS Some";
Floss [0] .draw ();
}
Private:
LEG LEG;
Floss floss [10];
Skelectron Skelectron;
}
// front limbs, hind limbs {limbs}}
Class foreLimb: public limb {
PUBLIC:
Void Draw ()
{
COUT << "Forelorb" << Endl;
Limb :: DRAW ();
}
}
Class backlimb: public limb {
PUBLIC:
Void Draw ()
{
Cout << "backlimb" << Endl;
Limb :: DRAW ();
}
}
// 四 {{{section, display = display limbs}, forelife [2], hind limbs [2]}
Class Extermity: public part {
PUBLIC:
Void Draw ()
{
COUT << "HAS A Left";
LeftForelimb.draw ();
Cout << "HAS a right"; RightForeLimb.draw ();
COUT << "HAS A Left";
Leftbacklimb.draw ();
COUT << "HAS a right";
Rightbacklimb.draw ();
}
Private:
Foreword manufactory; RightForeLimb;
Backlimb LeftbackLimb, RightBackLimb;
}
// internal organs {{section, display = display internal organs}, heart [1], spleen [1], liver [1], lung [2], stomach [1], intestinal [N], kidney [2]}
Class Harslet: Public Part {
PUBLIC:
Void Draw ()
{
Cout << "Harslet" << Endl;
COUT << "HAS A";
Heart.draw ();
COUT << "HAS A";
Spleen.draw ();
COUT << "HAS A";
Liver.draw ();
COUT << "HAS A Left";
LEFTLung.draw ();
COUT << "HAS a right";
Rightlung.draw ();
COUT << "HAS A";
Stomach.draw ();
COUT << "HAS Some";
INTESTINE [0] .draw ();
COUT << "HAS A Left";
LEFTKIDNEY.DRAW ();
COUT << "HAS a right";
Rightkidney.draw ();
}
Private:
Heart heart;
Spleen spleen;
Liver Liver;
Lung Leftlung, Rightlung;
Stomach Stomach;
Intestine Intestine [10];
Kidney Leftkidney; Rightkidney;
}
// 五 官 {{section, display = display five official}, ear [2], eyes [2], nose [1], mouth [1]}
Class Face: Public Part {
PUBLIC:
Void Draw ()
{
COUT << "face" << endl;
COUT << "HAS A Left";
Leftear.draw ();
COUT << "HAS a right";
RIGHTEAR.DRAW ();
COUT << "HAS A Left";
Lefteye.draw ();
COUT << "HAS a right";
Rightee.draw ();
COUT << "HAS A";
Nose.draw ();
COUT << "HAS A";
mouth.draw ();
}
Private:
Ear Leftear, RightEar;
Eye Leftee, RightEye;
Nose Nose;
Mouth mouth;
}
// Tail {{section, display = display tail}, tail [1], fluff [N], skeleton [1]} Class Tail: Public Part {
PUBLIC:
Void Draw ()
{
Cout << "tail" << Endl;
COUT << "HAS A";
stern.draw ();
COUT << "HAS A";
Skelectron.draw ();
COUT << "HAS Some";
Floss [0] .draw ();
}
Private:
Stern strn;
Floss floss [10];
Skelectron Skelectron;
}
// body {{, display = display body}, chest [1], abdominal [1], back [1], internal organs [1], fluff [N], skeleton [1]}
Class body: public part {
PUBLIC:
Void Draw ()
{
COUT << "body" << endl;
COUT << "HAS A";
Bosom.draw ();
COUT << "HAS A";
Abdomen.draw ();
COUT << "HAS A";
Backside.draw ();
COUT << "HAS A";
Harslet.draw ();
COUT << "HAS A";
Skelectron.draw ();
COUT << "HAS Some";
Floss [0] .draw ();
}
Private:
Bosom bosom;
Abdomen abdomen;
BACKSIDE BACKSIDE;
Harslet Harslet;
Floss floss [10];
Skelectron Skelectron;
}
// Head {{{section, Show = Show head}, five senses [1], beard [N], fluff [N], skeleton [1]}
Class head: public part {
PUBLIC:
Void Draw ()
{
COUT << "Head" << endl;
COUT << "HAS A";
Face.draw ();
COUT << "HAS A";
Skelectron.draw ();
COUT << "HAS Some";
Goatee [0] .draw ();
}
Private:
Face Face;
Goatee Goatee [10];
Skelectron Skelectron;
}
// Goat {{section, display = Show goat}, head [1], body [1], limbs [1], tail [1]}
Class Sheep: Public Part {
PUBLIC:
Void Draw ()
{
COUT << "sheep" << endl;
COUT << "HAS A";
Head.draw ();
COUT << "HAS A";
Body.draw ();
COUT << "HAS A";
EXTERMITY.DRAW (); cout << "HAS A";
Tail.draw ();
}
Private:
HEAD Head;
Body body;
EXTERMITY EXTERMITY
Tail tail;
}
Void main (void)
{
Sheep sheep;
Sheep.draw ();
cin.get ();
}
turn out:
Sheep
Has a head
HAS A FACE
HAS a Left Ear with Color: 0
HAS A Right Ear with Color: 0
HAS a Left Eye with color: 0
HAS a Right Eye with color: 0
HAS a Nose with Color: 0
Has a mouth with color: 0
Has A Skelectron with Color: 0
Has Some Goatee with Color: 0
HAS A Body
HAS A Bosom with Color: 0
HAS a abdomen with color: 0
HAS A Backside with Color: 0
Has a Harslet
HAS A Heart with Color: 0
HAS a SPLEEN with Color: 0
HAS a Liver with Color: 0
HAS a Left Lung with Color: 0
HAS a Right Lung with Color: 0
Has A Stomach with Color: 0
Has Some Intestine with Color: 0
HAS a left kidney with color: 0
HAS a Right Kidney with Color: 0
Has A Skelectron with Color: 0
Has Some Floss with Color: 0
Has a Has A Left foreLimb
Has a Leg with color: 0
Has A Skelectron with Color: 0
Has Some Floss with Color: 0
Has a right forelimb
Has a Leg with color: 0
Has A Skelectron with Color: 0
Has Some Floss with Color: 0
HAS a Left Backlimb
Has a Leg with color: 0
Has A Skelectron with Color: 0
Has Some Floss with Color: 0
HAS a Right Backlimb
Has a Leg with color: 0
Has A Skelectron with Color: 0
Has Some Floss with Color: 0
Has a tail
HAS A STERN WITH COLOR: 0
Has A Skelectron with Color: 0
Has Some Floss with Color: 0
The evil door is that after the end of this program, after the end of the end, the first time, there is no mistake, there is no mistake, there is no mistake, this is said, my finger is the upper floor ^ O ^.
Although I offer a source, I hope that I still have a serious input, and I can deepen my impression, I can practice fingering. The programmer's finger is also productivity.
However, this program is just a demo, using a fixed array and variables, in fact, the flexibility is still enough, some attributes are variable, such as the wool will fall, and the sheep of a leg or sheep, So pay attention to the elasticity, these variables must be changed to the pointer to dynamically increase or decrease. Ok, I said that I believe that readers are tired, or let everyone know.
2001/9/27
Ding Ning