×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / 请教:谁能出一个测试OOA或OOD的题目?最好明了简单(好表达)但是不是那么容易分析精屁(难回答)的题目?谢谢!
    • 把一个普通微波炉的功能用OO描述出来。
      • The most classic one is elevator.
    • 请把追MM的过程,用OO的方法来实现。
      • It is really cool!!!!!!
        • Could you post the anwser?
          • AfterGirl V1.0 (numnum, please revise my program)
            const float SUCCESSFUL = 1.5;

            class girl
            {
            public:
            girl(float looking, float age){ m_looking = looking; m_age = age; };

            float getLooking(){ return m_looking; };
            float getAge(){ return m_age; };
            private:
            float m_looking;
            float m_age;
            };

            class boy
            {
            public:
            boy(float money, float looking){m_money=money; m_looking = looking; m_luck = rand()%100;};
            bool suit(girl GIRL);
            private:
            float m_money;
            float m_looking;
            float m_luck;
            };

            bool boy::suit(girl GIRL)
            {
            float temp = m_money/100 + m_looking/100 + m_luck/100 - GIRL.getLooking()/100 - (30 - GIRL.getAge())/10;
            if ( temp > SUCCESSFUL )
            return true;
            else
            return false;
            };


            int main(int argc, char* argv[])
            {
            srand( (unsigned)time( NULL ) );

            girl *pGirl = new girl(100, 20);
            boy *pBoy = new boy(70, 80);

            if ( pBoy->suit(*pGirl) )
            printf("I made a girl friend. \n");
            else
            printf("I will go for the next one.\n");

            return 0;
            }
            • cool C++ man, if you can post the UML, that's excellent
            • haha, interesting
            • Haha, you are the best.
            • 师傅,收下我吧!
            • cool! but can explain why a good-looking girl and aged below 25, then no man can chase?
            • suggest add m_CookingAbility into class girl and m_Libido into boy and give them some consideration in boy::suit
            • bool boy::suit(girl GIRL)
              u'd better pass paramter as reference or pointer, otherwise, when u want to add a name field to class girl in next version, u get memory leak.
              • thanks for telling me.
              • Why there will be memory leak?
            • 小暇疵:age 用float太浪费空间,而且MM的age 永远都小于24, 用byte就够了, 还是PF,C++ 9段黑带高手:D
            • 另一个小暇疵 --- 变量没有采用匈牙利命名规则。。 对吧? 我是新手。。
            • I feel this program is not that profesional because of its witten style. All lines starting from the begining makes it not easy to be read. Just my opinion.
            • 你得增加一个构造函数,否则你的girl进不了栈。
            • 至少有两点可以改进
              1.use initializer instead of assignment in constructor function
              2.pass reference instead of value in bool boy::suit(girl GIRL)
    • How come I don't understand your question?