亚洲AV乱码一区二区三区女同,欧洲在线免费高清在线a,中文字幕丝袜四区,老少配老妇熟女中文高清

<s id="38axe"><nobr id="38axe"></nobr></s><abbr id="38axe"><u id="38axe"></u></abbr>

<sup id="38axe"></sup>
    <acronym id="38axe"></acronym>
  • <s id="38axe"><abbr id="38axe"><ins id="38axe"></ins></abbr></s>
    
    
        <s id="38axe"></s>

        2006年5月軟件設(shè)計(jì)師下午試題[5]

        軟件設(shè)計(jì)師 責(zé)任編輯:qingque 2008-08-06

        添加老師微信

        備考咨詢

        加我微信

        摘要:試題六(15分)閱讀下列說(shuō)明、圖和C++代碼,將應(yīng)填入(n)處的字句寫在答題紙的對(duì)應(yīng)欄內(nèi)?!菊f(shuō)明】某訂單管理系統(tǒng)的部分UML類圖如圖6-1所示。圖6-1中,Product表示產(chǎn)品,ProductList表示產(chǎn)品目錄,Order表示產(chǎn)品訂單,Orderltem表示產(chǎn)品訂單中的一個(gè)條目,OrderList表示訂單列表,SalesSystem提供訂單管理系統(tǒng)的操作接口。請(qǐng)完善類Or

        試題六(15分)
        閱讀下列說(shuō)明、圖和C++代碼,將應(yīng)填入 (n) 處的字句寫在答題紙的對(duì)應(yīng)欄內(nèi)。
        【說(shuō)明】
        某訂單管理系統(tǒng)的部分UML類圖如圖6-1所示。 
         
        圖6-1中,Product表示產(chǎn)品,ProductList表示產(chǎn)品目錄,Order表示產(chǎn)品訂單,
        Orderltem表示產(chǎn)品訂單中的一個(gè)條目,OrderList表示訂單列表,SalesSystem提供訂單
        管理系統(tǒng)的操作接口。
        請(qǐng)完善類Order的成員函數(shù)getOrderedAmount()和類SalesSystem的statistic()方
        法,各個(gè)類的屬性及部分方法定義參見(jiàn)下面的C++代碼。
        【C++代碼】
        class Product {//產(chǎn)品類
        private:
        string pid;//產(chǎn)品識(shí)別碼
        string description;//產(chǎn)品描述
        double price; //產(chǎn)品單價(jià)
        public:
        void setProductPrice(double price); //設(shè)置產(chǎn)品單價(jià)
        string getProductld(); //獲取產(chǎn)品識(shí)別碼
        string getProductDescription(); //獲取產(chǎn)品描述
        double getProductPrice();//獲取產(chǎn)品單價(jià)
        //其他成員省略
        };

        class ProductList{//產(chǎn)品列表類
        private:
        vector <Product> products;
        public:
        ProductList();
        Product getProductByIndex(int i);//獲得產(chǎn)品列表中的第i件產(chǎn)品
        void addProduct(Product t); //在產(chǎn)品列表中加入一件產(chǎn)品
        Product * getProductByID(string pid); //獲得識(shí)別碼為pid的產(chǎn)品指針
        unsigned int getProductAmount();//獲得產(chǎn)品列表中的產(chǎn)品數(shù)量
        };

        class OrderItem { //訂單條目類
        private:
        Product *productPtr;//指向被定購(gòu)產(chǎn)品的指針
        int quantity;//定購(gòu)數(shù)量
        public:
        OrderItem (Product *, int);
        Product * getProductptr();//獲取指向被定購(gòu)產(chǎn)品的指針
        int getQuantity (); //獲取被定購(gòu)產(chǎn)品的數(shù)量
        };

        class Order { //訂單類
        private:
        unsigned int orderid;//訂單識(shí)別號(hào)
        vector<OrderItem>items; //訂單內(nèi)容(訂單項(xiàng))
        public:
        Order(unsigned int orderid);
        //獲得識(shí)別碼為tid的產(chǎn)品在當(dāng)前訂單中被定購(gòu)的數(shù)量
        int getOrderedAmount(string tid);
        void additem(Product *productPtr,unsigned int n);//在訂單中增加—個(gè)訂單項(xiàng)
        //其他成員省略
        };

        class OrderList{ //訂單列表類
        prtvate:
        vector<Order> orders;
        public:
        OrderList();
        //Begin()返回指向訂單列表第一個(gè)元素的迭代器(指針)
        virtual vector<Order>::iterator OrderList::Begin();
        //End()返回指向訂單列表最后一個(gè)元素之后的迭代器(指向一個(gè)不存在的元素)
        virtual vector<Order>::iterator OrderList::End();
        void addOrder(Order t);//在訂單列表中加入一份訂單
        //其他成員省略
        };

        class SalesSystem{
        private:
        ProductList catalog∶ //產(chǎn)品目錄
        OrderList sales; //訂單列表
        public:
        SalesSystem();
        void statistic();//統(tǒng)計(jì)所有產(chǎn)品的定購(gòu)情況
        //其他成員省略
        };

        //在訂單中查找識(shí)別碼為tid的產(chǎn)品的定購(gòu)數(shù)量,若該產(chǎn)品沒(méi)有被定購(gòu),則返回0
        int Order::getOrderedAmount(string tid)
        { for (int k = 0; k < items.size(); k++){
         if ((1)  == tid)
         return  (2) ;
        }
        return 0;
        }

         

        //方法statistic()依次統(tǒng)計(jì)產(chǎn)品目錄中每個(gè)產(chǎn)品的訂購(gòu)總量,并打印輸出
        //每個(gè)產(chǎn)品的識(shí)別碼、描述、訂購(gòu)總量和訂購(gòu)金額
        void SalesSystem::statistic()
        {unsigned int k, t, ordered_qty = 0;
        vector<Order>::iterator tt; Product p;
        cout<<"產(chǎn)品識(shí)別碼\t描述\t\t定購(gòu)數(shù)量\t金額"<<endl;

        for(k=0; k<catalog.getProductAtnount(); k++){//遍歷產(chǎn)品列表
         p =(3) ; //從產(chǎn)品列表取得一件產(chǎn)品信息存入變量p
         ordered_qty = 0;
         //通過(guò)迭代器變量it遍歷訂單列表中的每一份訂單
         for(it = sales.Begin(); (4) ; it++){
        //根據(jù)產(chǎn)品識(shí)別碼獲得產(chǎn)品p在當(dāng)前訂單中被定購(gòu)的數(shù)量
        t =?。?)(p.getProductId());
        ordered_qty += t;
         }
         cout<<p.getProductId()<<"\t\t"<<p.getProductDescription()<<"\t\t";
         cout<<ordered_qty<<"\t\t"<<p.getProductPrice() * ordered_qty<<endl;
        }
        }


        [答案討論]

        [1]  [2]  [3]  [4]  [5]  [6]  

        溫馨提示:因考試政策、內(nèi)容不斷變化與調(diào)整,本網(wǎng)站提供的以上信息僅供參考,如有異議,請(qǐng)考生以權(quán)威部門公布的內(nèi)容為準(zhǔn)!

        軟考備考資料免費(fèi)領(lǐng)取

        去領(lǐng)取

        !
        咨詢?cè)诰€老師!