Thread: Help

  1. #1
    Registered User lsctt's Avatar
    Join Date
    Jun 2006
    Posts
    30

    Help

    somethings wrong, i don't know what, HELP!

    here is the code:

    Code:
    #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;
    }

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Please stop spamming the boards, lsctt, particularly other, unrelated threads.

    Replies here:

    http://cboard.cprogramming.com/showthread.php?t=79715
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed