• <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>

            把握命運,追逐夢想

            對自己所做的事要有興趣,同時還要能夠堅持不懈

            統(tǒng)計

            留言簿(1)

            閱讀排行榜

            評論排行榜

            C++作業(yè)一------------模擬電腦的組裝

            // stdafx.h : 標準系統(tǒng)包含文件的包含文件,
            // 或是經(jī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"
            // main.cpp : 定義控制臺應(yīng)用程序的入口點。
            //

            #include 
            "stdafx.h"
            #include
            "main.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].Init();
                    pCompter[i].Start();
                }


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


                delete []pCompter;
            }

            //CPU.h
            #pragma once
            #include
            "main.h"

            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;
            }

            //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
            #include "Memory.h"

            CMemory::CMemory(
            void)
            {
            }


            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;
            }
            //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 = 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;
            }

            //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();
            }
            ;
            //Computer.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
            <<"電腦的總價是"<<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;
                }


            }
            //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;
            }

            posted on 2009-08-12 18:10 把握命運 閱讀(322) 評論(0)  編輯 收藏 引用

            久久精品无码一区二区无码| 久久久久国色AV免费看图片| 性高湖久久久久久久久AAAAA| 手机看片久久高清国产日韩 | 久久久久一本毛久久久| 青青草原综合久久大伊人| 久久亚洲私人国产精品vA| 国产精品热久久无码av| 久久人人爽人人爽人人片AV麻烦| 99热成人精品热久久669| 亚洲婷婷国产精品电影人久久| 色欲久久久天天天综合网| 99久久国产综合精品麻豆| 亚洲欧美成人久久综合中文网| 国产成人久久精品一区二区三区| 久久久久久久久久免免费精品| 久久国产精品无码HDAV| 久久天天躁夜夜躁狠狠躁2022| 亚洲综合精品香蕉久久网97| 久久精品人人做人人爽电影蜜月| 一级a性色生活片久久无少妇一级婬片免费放 | 精品久久人人做人人爽综合| 国内精品久久久久影院优| 亚洲精品成人久久久| 久久久精品久久久久特色影视| 91视频国产91久久久| 久久久久久九九99精品| 99蜜桃臀久久久欧美精品网站 | 无码精品久久一区二区三区 | 91麻豆国产精品91久久久| 亚洲欧美久久久久9999| 日韩精品无码久久一区二区三| 久久久国产精品福利免费| 久久精品国产免费一区| 久久精品国产亚洲欧美| 99久久国产免费福利| 国产69精品久久久久99| 国产激情久久久久影院老熟女| 久久99精品国产麻豆蜜芽| 久久毛片免费看一区二区三区| 久久人人爽人人澡人人高潮AV |