i'm making it for my cousin, idk whats wrong with it help!!!
here it is:
Code:/* Name: Critter Farm Copyright: N\A Author: Trevor S. Lusk Date: 01/06/06 18:55 Description: */ #include <iostream> using namespace std; class critter { public: critter(int hunger=0, int boredom=0); void talk(); void eat(int food=4); void play(int fun=4); private: int m_Hunger; int m_Boredom; int getMood() const; void passTime(int time = 1); }; critter::critter(int hunger, int boredom): m_Hunger(hunger), m_Boredom(boredom) {} inline int getMood() const { return (m_Hunger + m_Boredom); } void critter::passtime(int time) { m_Hunger += time; m_Boredom += time; } void critter::talk() { cout << "Cindy, I'm "; int mood=getMood(); if (mood > 15) cout<<"mad. (you need to pay more attention to you're pet)"; else if (mood > 10) cout<<"Frustrated.\n"; else if (mood > 5) cout<<"okay, thanks for asking.\n"; else cout<<"Happy, you're such a good owner!\n"; passtime(); } void critter::Eat (int food) { cout<<"Brruuupp! yumm! you're such a good cook! #1 :)\n"; m_Hunger -= food; if (m_hunger<0) m_hunger=0; passtime(); } void critter::play(int fun) { cout<<"weeeee! Cindy your so fun!"; m_Boredom -= fun; if (m_Boredom < 0) m_Boredom = 0; passtime(); } int main() { critter crit; crit.talk(); int choice; do { cout << "\nDragon Caretaker\n\n"; cout << "0-Quit\n"; cout << "1-Listen to your baby dragon\n"; cout << "2-Feed your baby dragon\n"; cout << "3-play with your dragon\n\n"; cout << "choice :"; cin >> choice; switch (choice) { case 0; cout << "good bye, I'll miss you cindy! :(\n"; break; case 1; crit.talk(); break; case 2; crit.eat(); cout << "Yumm! thanks cindy, your a good cook!\n"; break; case 3; crit.play(); break; default; cout << "ciny, I'm confused!?!\n"; } }while (choice !=0); cout<<"hit enter to Exit"; cin.ignore(cin.rdbuf()->in_avail()+1); return 0; }



LinkBack URL
About LinkBacks


