⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animals.h

📁 通过类型姓名年龄类别来显示动物
💻 H
字号:

//************************
//*	File Animals.H       *   
//************************

     //	declarations of Animals:Wolve, Tiger, Lion, Bear 
    //  Coyote, WildCat.Leopard, Fox, Dogs.
#ifndef __ANIMALS_DEF__
#define __ANIMALS_DEF__

#include<iostream.h>
#include<string.h>

#define MAX_NUMBER_OF_ANIMALS 20         
typedef enum { FALSE , TRUE } bool_t;
typedef enum { CANINES, FELINES, RAPTILES, BIRDS } AnimalKindType;

#define GENERIC_ANIMAL_ID 0
#define BEAR_ID		1
#define TIGER_ID	2
#define LION_ID		3
#define WOLVE_ID	4
#define COYOTE_ID   5
#define WILDCAT_ID  6
#define LEOPARD_ID  7
#define FOX_ID      8
#define DOGS_ID     9


//************************************************************************

class Animal                          // Define class base Animal

{
   protected:

       char	mName[50];
       AnimalKindType mKindOfAnimal;   // Canines or Felines
	   int	mAge;
	   char	mSex;				       // Can be M or F
	   int	mCage;
	   int   mUniqueNumber;		       // Animal unique number
       static int mCounter;            // Count of Animal
	   int   mAnimalTypeID; 		   // Identifies Lions, Tigers, Bears...
	   Animal *mNext;

   public:

	   virtual void GetAnimalInfo( void );
	  
	   char * AnimalTypeString( void );
      
	   Animal();                         // Default constructor
	  
	   Animal( char * Name, AnimalKindType type, int Age, char Sex, int Cage = 0);
      
	  ~Animal();                        // Destructor

      // interfaces
	  int GetUniqueNumber ( void )      // To got the unique number	
	  { return mUniqueNumber; };

      void SetName ( char * Name )       // To get the name of the Animal
	  { strcpy ( mName, Name ); };
      
	  void GetName ( char * Name)             
	  { strcpy ( mName, Name ); };

      void SetSex( char Sex )            // To got the sex of the Animal
	  { mSex = Sex; };
      
	  char GetSex()
	  { return mSex; } ;

      
	  void SetAge( int Age )             // To got the Age of the Animal
	  { mAge = Age; };
      
	  int GetAge()
	  {return mAge; } ;
	  
	  void BirthDay()		             // Incremants age by 1
	  { mAge++; };

      void SetCage( int Cage )           // To got the cage number
	  { mCage = Cage; };
      
	  int GetCage()
	  { return mCage; };

      void SetAnimalType( AnimalKindType Type ) // Type of the Animal
	  { mKindOfAnimal = Type; };
      
	  AnimalKindType GetAnimalType()
	  { return mKindOfAnimal; };

	  void SetAnimalTypeID ( int ID )           // The Animal ID
	  {  mAnimalTypeID = ID ;};
	  
	  int GetAnimalTypeID ( void )
	  {  return mAnimalTypeID ;};

	  void SetNext(Animal *next)
	  { mNext = next; };
	  
	  Animal *GetNext(void)
	  { return mNext; };

	  virtual void Display();               // prints info about Animal

};

//************************************************************************
class Wolve : public Animal        //Wolve class definition

{
   public:

      
	  virtual void Display(void);      // Display information about Wolve
   
      virtual void GetAnimalInfo();    // Display Wolve Id
      
      Wolve();                         // Constructor
	  
	  Wolve( char * Name, int Age, char Sex, int Cage );
      
	  ~Wolve();                       // Destructor
};

//************************************************************************

class Bear : public Animal              // Bear class definition

{
   private: 

      char mColor[50]; 
	  
   public:

      
	   Bear();                           // Default Constructor
	  
	  // Normal constructor
	  Bear( char * Name, char * Color, int Age, char Sex, int Cage );
      
	  ~Bear();                          // Destructor
	  
	  void SetColor ( char * Color )    // to set the color function
	  { strcpy ( mColor, Color ); } ;
	  
	  void GetColor ( char * Color )    // to get the color
	  { strcpy ( Color, mColor ); } ;
      
	  virtual void Display(void);       // Display Bear information
      
	  virtual void GetAnimalInfo();     // Display Bear ID
};

//************************************************************************

class Lion : public Animal           // Lion class definition

{
   private: 

	   int mPride;

   public:

      Lion();                         // Default Constructor
	  
	  // Normal constructor
      Lion( char * Name, int Pride, int Age, char Sex, int Cage );
      
	  ~Lion();                        // Destructor

      
	  void SetPride( int Pride)       // set Pride function
	  { mPride = Pride; } ;
      
	  int GetPride()                  // Get Pride function
	  { return mPride; };
      
	  virtual void Display(void);     // Display Lion information
      
	  virtual void GetAnimalInfo();   // Get Lion ID
};

//**********************************************************************

class Tiger : public Animal        //Tiger class definition
        
{
   private: 

      double mProtein;

   public:

      Tiger();                     // Default constructor
	  
	  // Normal constructor
      Tiger(char * Name, double Protein, int Age, char Sex, int Cage );
      
	  ~Tiger();                    //destructor

	  void SetProtein ( double Protein )   // Set Protein function
	  { mProtein = Protein; };
	  
	  double GetProtein (void)             // Get Protein function
	  { return mProtein; };
   
	  virtual void Display(void);             // Tiger information
   
      virtual void GetAnimalInfo();           // Tiger ID
};

//************************************************************************



class Coyote : public Animal        //Coyote class definition

{
   public:

     
	   virtual void Display(void);      // Display information about Coyote
      
       virtual void GetAnimalInfo();    // Display Coyote Id
      
       Coyote();                     // Constructor
	  
	   Coyote( char * Name, int Age, char Sex, int Cage );
      
	   ~Coyote();                    // Destructor
};

//************************************************************************

class WildCat : public Animal        //WildCat class definition
        
{
   private: 

      double mProtein;

   public:

      WildCat();                     // Default constructor
	  
	  // Normal constructor
      WildCat(char * Name, double Protein, int Age, char Sex, int Cage );
      
	  ~WildCat();                    //destructor

	  
	  void SetProtein ( double Protein )   // Set Protein function
	  { mProtein = Protein; };
	  
	  double GetProtein (void)             // Get Protein function
	  { return mProtein; };
   
	  virtual void Display(void);             // WildCat information
   
      virtual void GetAnimalInfo();           // WildCat ID
};

//***********************************************************************

class Leopard : public Animal        //Leopard class definition
        
{
   private: 

      double mProtein;

   public:

      Leopard();                     // Default constructor
	  
	  // Normal constructor
      Leopard(char * Name, double Protein, int Age, char Sex, int Cage );
      
	  ~Leopard();                    //destructor

	  void SetProtein ( double Protein )   // Set Protein function
	  { mProtein = Protein; };
	  
	  double GetProtein (void)             // Get Protein function
	  { return mProtein; };
   
	  virtual void Display(void);             // Leopard information
   
	  virtual void GetAnimalInfo();           // Leopard ID
};


//***********************************************************************


class Fox : public Animal           //Fox class definition

{
   public:

      virtual void Display(void);      // Display information about Fox
      
	  virtual void GetAnimalInfo();    // Display Fox Id
      
	  Fox();                        // Constructor
	  
	  Fox( char * Name, int Age, char Sex, int Cage );
      
	  ~Fox();                       // Destructor
};

//************************************************************************


class Dogs : public Animal              // Dogs class definition

{
   private: 

      char mColor[50]; 
	  
   public:

      Dogs();                           // Default Constructor

	  // Normal constructor
	  Dogs( char * Name, char * Color, int Age, char Sex, int Cage );
      
	  ~Dogs();                          // Destructor
	  
	  void SetColor ( char * Color )    // to set the color function
	  { strcpy ( mColor, Color ); } ;
	  
	  void GetColor ( char * Color )    // to get the color
	  { strcpy ( Color, mColor ); } ;
      
	  virtual void Display(void);       // Display Dogs information
      
	  virtual void GetAnimalInfo();     // Display Dogs ID
};

//************************************************************************
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -