reellearning

User Defined Type - VPet.cpp

Jun 4th, 2012
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. /*
  2.  * Vpet.cpp
  3.  *
  4.  *  Created on: Aug 10, 2011
  5.  *      Author: Derek
  6.  */
  7.  
  8.  
  9. #include "VPet.h"
  10.  
  11. VPet::VPet(double w, bool hun):weight(w),hungry(hun)
  12. {
  13. }
  14.  
  15. VPet::VPet():weight(100),hungry(true)
  16. {
  17. }
  18.  
  19. void VPet::feedPet(int amt)
  20. {
  21.     if(amt >= weight * 0.5)
  22.     {
  23.         hungry = false;
  24.     }
  25.     else
  26.     {
  27.         hungry = true;
  28.     }
  29.  
  30.     weight = weight + 0.25 * amt;
  31. }
  32.  
  33. double VPet::getWeight() const
  34. {
  35.     return weight;
  36. }
  37.  
  38. bool VPet::getHungry() const
  39. {
  40.     return hungry;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment