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

            把握命運,追逐夢想

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

            統計

            留言簿(1)

            閱讀排行榜

            評論排行榜

            C++作業一------------模擬電腦的組裝

            // stdafx.h : 標準系統包含文件的包含文件,
            // 或是經常使用但不常更改的
            // 特定于項目的包含文件
            //

            #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 : 定義控制臺應用程序的入口點。
            //

            #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 把握命運 閱讀(319) 評論(0)  編輯 收藏 引用

            国产精品一区二区久久精品| 色老头网站久久网| 久久精品国产WWW456C0M| 午夜视频久久久久一区| 人妻精品久久无码专区精东影业 | 久久久久久久人妻无码中文字幕爆| www.久久热| 99久久国产亚洲综合精品| 97久久精品无码一区二区| 亚洲欧美日韩久久精品| 99国产精品久久| 久久AV高潮AV无码AV| 国产精品成人久久久久久久| 久久国产热精品波多野结衣AV| 久久人妻少妇嫩草AV蜜桃| 久久91亚洲人成电影网站| 97久久婷婷五月综合色d啪蜜芽| 久久久久久亚洲精品不卡| 久久99精品久久久久久| 综合网日日天干夜夜久久| 久久这里只有精品视频99| 久久综合九色综合97_久久久| 色偷偷久久一区二区三区| 亚洲人成电影网站久久| 日日狠狠久久偷偷色综合0| A级毛片无码久久精品免费| 久久国产精品99国产精| 亚洲日本va中文字幕久久| 久久亚洲中文字幕精品一区| 污污内射久久一区二区欧美日韩| 777久久精品一区二区三区无码| aaa级精品久久久国产片| 久久久无码精品亚洲日韩按摩| 久久久久久久波多野结衣高潮 | 久久综合狠狠色综合伊人| 999久久久免费精品国产| 777米奇久久最新地址| 国产精品毛片久久久久久久| 99久久99久久精品免费看蜜桃| 91久久精品91久久性色| 四虎国产精品免费久久久|