• <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)  編輯 收藏 引用

            狠狠久久亚洲欧美专区 | 精品久久久久久久中文字幕 | 国产精品久久久久一区二区三区| 国产高潮久久免费观看| 亚洲人成无码网站久久99热国产| 久久亚洲精品无码VA大香大香| 久久国产免费观看精品3| 久久精品中文字幕第23页| 国产aⅴ激情无码久久| 成人午夜精品久久久久久久小说| 久久人人爽人人爽人人爽| 国内精品久久久人妻中文字幕| 久久亚洲中文字幕精品一区| 精品久久久久久无码专区| 欧美精品一区二区久久| 99久久成人国产精品免费| 久久久久久综合网天天| 国产福利电影一区二区三区,免费久久久久久久精 | 久久国产综合精品五月天| 国内精品久久久久伊人av| 色综合久久夜色精品国产| 精品人妻伦九区久久AAA片69 | 久久夜色精品国产www| 亚洲国产精品婷婷久久| 午夜天堂精品久久久久| 一本色道久久综合| 久久久久噜噜噜亚洲熟女综合 | 中文精品99久久国产| 久久精品国产一区二区三区| 国产精品一久久香蕉国产线看| 日韩人妻无码精品久久久不卡| 一级a性色生活片久久无| 午夜视频久久久久一区| 久久一区二区三区免费| 久久精品二区| 久久国产香蕉一区精品| 久久99国产精品成人欧美| a级成人毛片久久| 久久精品国产99国产电影网 | 一本色综合网久久| 久久久久久亚洲Av无码精品专口|