• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            把握命運(yùn),追逐夢想

            對自己所做的事要有興趣,同時(shí)還要能夠堅(jiān)持不懈

            統(tǒng)計(jì)

            留言簿(1)

            閱讀排行榜

            評論排行榜

            C++編程練習(xí)作業(yè)

            //Computer.h
            #pragma once
            #include
            "CPU.h"
            #include
            "Memory.h"
            #include
            "MainBoard.h"
            #include
            "Monitor.h"

            class CComputer
            {
            private:
                CCPU m_cpu;
                CMemory m_memory;
                CMainBoard m_mainBoard;
                CMonitor m_monitor;
            public:
                CComputer(
            void);
            public:
                
            ~CComputer(void);

                
            void setCpuFrequency(double frequency);
                
            void setCpuFactory(char name);
                
            void setMemorySize(int size);
                
            void setMemoryFactory(char name);
                
            void setMonitorSize(int size ,Sort sort);
                
            void setMonitorFactory(char name);
                
            void setMainBoardFactory(char name);
                
            void printWholePrice();
                
            void printConfig();
                
            void Init();
                
            void Start();
            }
            ;
            //Compter.cpp
            #include "Computer.h"
            #include
            <iostream>
            using namespace std;

            CComputer::CComputer(
            void)
            {
            }


            CComputer::
            ~CComputer(void)
            {
            }


            void CComputer::setCpuFrequency(double frequency)
            {
                
            this->m_cpu.setFrequency(frequency);
            }

            void CComputer::setCpuFactory(char name)
            {
                
            this->m_cpu.setFactoryName(name);
            }

            void CComputer::setMemorySize(int size)
            {
                
            this->m_memory.setSize(size);
            }

            void CComputer::setMemoryFactory(char name)
            {
                
            this->m_memory.setFactoryName(name);
            }

            void CComputer::setMonitorSize(int size ,Sort sort)
            {
                
            this->m_monitor.setSize(size);
                
            this->m_monitor.setSort(sort);
            }

            void CComputer::setMonitorFactory(char name)
            {
                
            this->m_monitor.setFactoryName(name);
            }

            void CComputer::setMainBoardFactory(char name)
            {
                
            this->m_mainBoard.setFactoryName(name);
            }

            void CComputer::printWholePrice()
            {
                
            double price = this->m_cpu.getPrice();
                price
            +=this->m_mainBoard.getPrice();
                price
            +=this->m_memory.getPrice();
                price
            += this->m_monitor.getPrice();

                cout
            <<"電腦的總價(jià)是"<<price<<endl;
            }

            void CComputer::printConfig()
            {
                cout
            <<"電腦配置:"<<endl;
                cout
            <<"CPU:"<<this->m_cpu.getFactoryName()<<"\t"<<this->m_cpu.getFrequency()<<"GHz"<<endl;
                cout
            <<"Memory:"<<this->m_memory.getFactoryName()<<"\t"<<this->m_memory.getSize()<<"MB"<<endl;
                cout
            <<"MainBoard:"<<this->m_mainBoard.getFactoryName()<<endl;
                cout
            <<"Monitor:"<<this->m_monitor.getFactoryName()<<"\t"<<this->m_monitor.getSize();
                
            if(this->m_monitor.getSort()== COMMON)
                
            {
                    cout
            <<"普通屏"<<endl;
                }

                
            else if(this->m_monitor.getSort() == LIQUID)
                
            {
                    cout
            <<"液晶屏"<<endl;
                }


            }


            void CComputer::Init()
            {
                
            this->m_mainBoard.Plug(&this->m_cpu,&this->m_memory);
                
            }

            void CComputer::Start()
            {
                
            if(this->m_mainBoard.SelfCheck())
                
            {
                    cout
            <<"配置匹配,順利啟動"<<endl;
                }

                
            else
                
            {
                    cout
            <<"配置不匹配,啟動失敗"<<endl;
                }


            }
            //CPU.h
            #pragma once

            class CCPU
            {
            private:
                
            char m_factoryName;
                
            double m_frequency;
            public:
                CCPU(
            void);
            public:
                
            ~CCPU(void);

                
            void setFactoryName(char name);
                
            char getFactoryName();
                
            double getPrice();
                
            void setFrequency(double frequency);
                
            double getFrequency();
            }
            ;
            //CPU.cpp
            #include "CPU.h"

            CCPU::CCPU(
            void)
            {
                
            this->m_factoryName = '\0';
                
            this->m_frequency = 0;
            }


            CCPU::
            ~CCPU(void)
            {
            }


            void CCPU::setFactoryName(char name)
            {
                
            this->m_factoryName = name;
            }


            void CCPU::setFrequency(double frequency)
            {
                
            this->m_frequency = frequency;

            }


            char CCPU::getFactoryName()
            {
                
            return this->m_factoryName;
            }


            double CCPU::getPrice()
            {
                
            if(this->m_factoryName == 'A')
                    
            return this->m_frequency*800;
                
            if(this->m_factoryName == 'B')
                    
            return this->m_frequency*700;
                
            if(this->m_factoryName == 'C')
                    
            return this->m_frequency*600;
            }


            double CCPU::getFrequency()
            {
                
            return this->m_frequency;
            }

            //MainBoard.h
            #pragma once
            #include
            "CPU.h"
            #include
            "Memory.h"

            class CMainBoard
            {
            private:
                
            char m_factoryName;
                CCPU 
            *m_pCpu;
                CMemory 
            *m_pMemory;
                
            public:
                CMainBoard(
            void);
            public:
                
            ~CMainBoard(void);

                
            void setFactoryName(char name);
                
            char getFactoryName();
                
            double getPrice();
                
            void Plug(CCPU* pCpu,CMemory* pMemory );
                
            bool SelfCheck();
            }
            ;
            //MainBoard.cpp
            #include "MainBoard.h"

            CMainBoard::CMainBoard(
            void)
            {
                
            this->m_pCpu = 0;
                
            this->m_factoryName = '\0';
                
            this->m_pMemory = 0;
            }


            CMainBoard::
            ~CMainBoard(void)
            {
            }


            void CMainBoard::setFactoryName(char name)
            {
                
            this->m_factoryName = name;
            }

            char CMainBoard::getFactoryName()
            {
                
            return this->m_factoryName;
            }

            double CMainBoard::getPrice()
            {
                
            if(this->m_factoryName == 'A')
                    
            return 600;
                
            if(this->m_factoryName == 'B')
                    
            return 500;
                
            if(this->m_factoryName == 'C')
                    
            return 400;
            }


            void CMainBoard::Plug(CCPU *pCpu, CMemory *pMemory)
            {
                
            this->m_pCpu = pCpu;
                
            this->m_pMemory;
            }


            bool CMainBoard::SelfCheck()
            {
                
            if((this->m_pCpu->getFactoryName() == 'A'||this->m_pCpu->getFactoryName()=='B'||
                    
            this->m_pCpu->getFactoryName() == 'C')&&(this->m_pMemory->getFactoryName() == 'A' ||
                    
            this->m_pMemory->getFactoryName() == 'B'||this->m_pMemory->getFactoryName()=='C'))
                    
            return true;
                
            else
                    
            return false;
            }

            //Memory.h
            #pragma once

            class CMemory
            {
            private:
                
            char m_factoryName;
                
            int m_size;
            public:
                CMemory(
            void);
            public:
                
            ~CMemory(void);

                
            void setFactoryName(char name);
                
            char getFactoryName();
                
            double getPrice();
                
            void setSize(int size);
                
            int getSize();
            }
            ;
            //Memory.cpp
            CMemory::~CMemory(void)
            {
                
            this->m_factoryName = '\0';
                
            this->m_size =0;
            }


            void CMemory::setFactoryName(char name)
            {
                
            this->m_factoryName = name;
            }

            char CMemory::getFactoryName()
            {
                
            return this->m_factoryName;
            }

            double CMemory::getPrice()
            {
                
            if(this->m_factoryName == 'A')
                    
            return this->m_size*0.2;
                
            if(this->m_factoryName == 'B')
                    
            return this->m_size*0.18;
                
            if(this->m_factoryName == 'C')
                    
            return this->m_size*0.16;
            }


            void CMemory::setSize(int size)
            {
                
            this->m_size = size;
            }


            int CMemory::getSize()
            {
                
            return this->m_size;
            }
            //Monitor.h
            #pragma once

            enum Sort{COMMON,LIQUID};

            class CMonitor
            {
            private:
                
            char m_factoryName;
                
            int m_size;
                Sort m_sort;

            public:
                CMonitor(
            void);
            public:
                
            ~CMonitor(void);

                
            void setFactoryName(char name);
                
            char getFactoryName();
                
            double getPrice();
                
            void setSize(int size);
                
            void setSort(Sort sort);
                
            int getSize();
                Sort getSort();
            }
            ;
            //Monitor.cpp
            #include "Monitor.h"

            CMonitor::CMonitor(
            void)
            {
            }


            CMonitor::
            ~CMonitor(void)
            {
            }


            void CMonitor::setFactoryName(char name)
            {
                
            this->m_factoryName = name;
            }

            char CMonitor::getFactoryName()
            {
                
            return this->m_factoryName;
            }

            double CMonitor::getPrice()
            {
                
            double price =0;
                
            if(this->m_factoryName == 'A')
                    price 
            =this->m_size*90;
                
            else if(this->m_factoryName == 'B')
                    price 
            =this->m_size*80;
                
            else if(this->m_factoryName == 'C')
                    price 
            =this->m_size*70;

                
            if(this->m_sort == COMMON)
                    price 
            *= 0.8;
                
            else if(this->m_sort == LIQUID)
                    price 
            *= 1.2;

                
            return price;
            }

            void CMonitor::setSize(int size)
            {
                
            this->m_size = size;
            }

            void CMonitor::setSort(Sort sort)
            {
                
            this->m_sort = sort;
            }


            int CMonitor::getSize()
            {
                
            return this->m_size;
            }


            Sort CMonitor::getSort()
            {
                
            return this->m_sort;
            }
            //stdafx.h
            // stdafx.h : 標(biāo)準(zhǔn)系統(tǒng)包含文件的包含文件,
            // 或是經(jīng)常使用但不常更改的
            // 特定于項(xiàng)目的包含文件
            //

            #pragma once


            #define WIN32_LEAN_AND_MEAN        // 從 Windows 頭中排除極少使用的資料
            #include 
            <stdio.h>
            #include 
            <tchar.h>
            #include
            <stdlib.h>



            // TODO: 在此處引用程序需要的其他頭文件
            #include"CPU.h"
            #include
            "MainBoard.h"
            #include
            "Memory.h"
            #include
            "Monitor.h"
            #include
            "Computer.h"
            //stdfax.cpp
            // stdafx.cpp : 只包括標(biāo)準(zhǔn)包含文件的源文件
            // C++3.pch 將作為預(yù)編譯頭
            // stdafx.obj 將包含預(yù)編譯類型信息

            #include 
            "stdafx.h"

            // TODO: 在 STDAFX.H 中
            // 引用任何所需的附加頭文件,而不是在此文件中引用

            // C++3.cpp : 定義控制臺應(yīng)用程序的入口點(diǎn)。
            //

            #include 
            "stdafx.h"

            char name[3= {'A','B','C'};
            int memSize[3= {128,256,512};
            int monSize[4= {14,15,17,19};
            Sort sort[
            2= {COMMON,LIQUID};
            double frequency[3={1.33,1.67,2.0};

            void FunMain();

            int _tmain(int argc, _TCHAR* argv[])
            {
                
                FunMain();
                
                
            return 0;
            }


            void FunMain()
            {
                CComputer 
            *pCompter = new CComputer[10];
                
            for(int i = 0; i<10; i++)
                
            {
                    pCompter[i].setCpuFrequency(frequency[rand()
            %3]);
                    pCompter[i].setCpuFactory(name[rand()
            %3]);
                    pCompter[i].setMainBoardFactory(name[rand()
            %3]);
                    pCompter[i].setMemoryFactory(name[rand()
            %3]);
                    pCompter[i].setMonitorFactory(name[rand()
            %3]);
                    pCompter[i].setMemorySize(memSize[rand()
            %3]);
                    pCompter[i].setMonitorSize(monSize[rand()
            %4],sort[rand()%2]);

                }


                
            for(int i = 0; i<10; i++)
                
            {
                    pCompter[i].printConfig();
                    pCompter[i].printWholePrice();
                }


                delete []pCompter;
            }


            posted on 2009-08-07 16:41 把握命運(yùn) 閱讀(302) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            无码任你躁久久久久久老妇| 国内高清久久久久久| 久久笫一福利免费导航| 久久久久久亚洲精品成人| 久久久久亚洲精品男人的天堂| 久久久久亚洲av无码专区| 日本久久久久久久久久| 国产成人精品白浆久久69| 狠狠色丁香久久婷婷综合| 久久久久久亚洲精品无码| 久久精品国产免费| 人妻丰满AV无码久久不卡| 久久青青草视频| 久久久久一级精品亚洲国产成人综合AV区 | 97久久国产露脸精品国产| 国产精品一区二区久久精品无码| 无码伊人66久久大杳蕉网站谷歌| 久久久久九九精品影院| 色综合久久中文综合网| 久久精品国产亚洲AV大全| 久久久久av无码免费网| 日日狠狠久久偷偷色综合96蜜桃| 91亚洲国产成人久久精品网址| 国产精品无码久久综合 | 精品久久久久久久国产潘金莲| 精品久久人人爽天天玩人人妻| 日本道色综合久久影院| 国产精品免费福利久久| 国产精品美女久久久久久2018| 亚洲va久久久噜噜噜久久| 久久久www免费人成精品| 久久综合久久综合亚洲| 欧美日韩久久中文字幕| 精品伊人久久久| 亚洲人成网亚洲欧洲无码久久| 99精品国产免费久久久久久下载 | 国产精品久久久久久吹潮| 国产三级久久久精品麻豆三级| 精品国产VA久久久久久久冰| 麻豆亚洲AV永久无码精品久久| 久久夜色精品国产欧美乱|