GaryBob 发表于 2016-10-20 15:16:29

自学之路,好累好累,好视频

guizinj 发表于 2016-12-30 00:41:35

来个回复,正努力中

guizinj 发表于 2016-12-30 00:42:15

真的很不错

国宝包 发表于 2017-7-30 21:07:19

回复就行?

fisheryao 发表于 2017-12-4 10:41:04

好资料

回村的诱惑 发表于 2017-12-12 11:21:17

支持66666666666666666666666666666666666

suboning333 发表于 2018-10-19 08:51:03

需要这么多鱼币,下载不了

ghy520 发表于 2018-10-25 21:46:18

挣个鱼币下载个文件。。

HelloSeal 发表于 2018-11-1 10:59:20

小甲鱼,你这对象没给我介绍完呐!!难怪我看到后面的代码,咦?怎么突然就写了那么多了。。。
{:10_254:}有没有什么途径可以补上啊

HelloSeal 发表于 2018-11-5 23:58:11

小甲鱼分享的代码好多bug!!!
#include <iostream>
#include <Windows.h>

#define FULL_GAS 85

class Car
{
public:
        std::string color;
        std::string engine;
        unsigned int gas_tank;
        unsigned int wheel;

        void setColor(std::string col);
        void setEngine(std::string eng);
        void setWheel(unsigned int whe);
        void fill_tank(int liter);
        int running(void);
        void warning(void);
};

void Car::setColor(std::string col)
{
        color = col;
}

void Car::setEngine(std::string eng)
{
        engine = eng;
}

void Car::setWheel(unsigned int whe)
{
        wheel = whe;
}

void Car::fill_tank(int liter)
{
        gas_tank += liter;
}

int Car::running(void)
{
        std::cout << "Speed = 120\n";
        gas_tank--;
        std::cout << "Gas remaining " << 100 * gas_tank / FULL_GAS << "%" << "\n";

        return gas_tank;
}

void Car::warning(void)
{
        std::cout << "WARNING!!" << " Gas remaining " << 100 * gas_tank / FULL_GAS << "%!! \n";
}

int main()
{
        char i;
        Car mycar;

        mycar.setColor("WHITE");
        mycar.setEngine("V8");
        mycar.setWheel(4);

        mycar.gas_tank = FULL_GAS;

        unsigned int gas_tank;
        while (gas_tank = mycar.running())
        {
                if (gas_tank <= 0)
                {
                        std::cout << "The fuel has run out! The car stops!!\n";
                        break;
                }
                if (gas_tank < 10)
                {
                        mycar.warning();
                        std::cout << "Do you need to fill the fuel? (Y/N)\n";
                        std::cin >> i;
                        if ('Y'==i || 'y'==i)
                        {
                                mycar.fill_tank(FULL_GAS - gas_tank);
                        }
                }
        }

        return 0;
}
页: 1 [2]
查看完整版本: 第十四讲 给大家介绍对象