Module 1. C++ Classes Exercise Answers

1.
   class ZooAnimal  
   {
    private:
      char *name;
      int cageNumber;
      int weightDate;
      int weight;
    public:
      void Create (char*, int, int, int);
      void Destroy (); // destroy function
      char* reptName ();
      int daysSinceLastWeighed (int today);
   };


2.
   // -------- member function to return the number of days
   // -------- since the animal was last weighed
   int ZooAnimal::daysSinceLastWeighed (int today)
   {
    int startday, thisday;
    thisday = today/100*30 + today - today/100*100;
    startday = weightDate/100*30 + weightDate - weightDate/100*100;
    if (thisday < startday) 
        thisday += 360;
    return (thisday-startday);
   }


3.
    cout << "This animal's name is " << bozo.reptName () << endl;