当前位置: 首页>>代码示例>>C++>>正文


C++ Pair::getTime方法代码示例

本文整理汇总了C++中Pair::getTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Pair::getTime方法的具体用法?C++ Pair::getTime怎么用?C++ Pair::getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pair的用法示例。


在下文中一共展示了Pair::getTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
    
    int getValidInput = 0;
    string validSymbol;
    while (true) {
        
        while (getValidInput == 0) {
            //Input valid stock symbol
            cout<<"Please input the stock symbol or name"<<endl;
            string inputSymbol;
            getline(cin,inputSymbol);
            cout<<"The stock symbol or name you've entered is "<<inputSymbol<<endl;
            
            vector<string> similarSymbols = center->getStockSymbols(inputSymbol);
            if(similarSymbols.size() == 0){
                cout<<"could not find the valid stock symbol that matches your input"<<endl;
            }
            else if(similarSymbols.size() == 1){
                validSymbol = similarSymbols[0];
                cout<<"We find a valid stock symbol " << validSymbol<<endl;
                getValidInput = 1;
            }
            else{
                cout<<"We find more than 1 symbols that matches your input"<<endl;
                for(int i=0; i<similarSymbols.size(); i++){
                    cout<<similarSymbols[i]<<endl;
                }
                cout<<"Please make input again"<<endl;
            }
        }
        getValidInput = 0;
        
        cout<<"What do you want to do with the stock "<<validSymbol<<"? 1. Add it to the database. 2. Remove it from the database."<<endl;
        string option;
        getline(cin,option);
        int opt = atoi(option.c_str());
        
        if(opt == 1){
            //Download file from internet
            string fileName = center->downloadStock(validSymbol);
            cout<<"fileName is "<<fileName<<endl;
            
            //Parse the csv file
            center->createStock(validSymbol, fileName);
            center->printAllStocks();
        }
        else if(opt ==2){
            center->removeStock(validSymbol);
        }
        else{
            cout<<"Invalid command"<<endl;
        }
        
        cout<<"What do you want to process next. 1. Get stock history. 2. Get future prices. 3. Get the future <time,price> pairs. 4. Get suggestions for the current stock"<<endl;
        
        getline(cin,option);
        opt = atoi(option.c_str());
        
        if(opt == 1){
            //Print the stock history
            cout<<"Print the stock history"<<endl;
            vector<Pair*> history = center->getStockHistory(validSymbol);
            for(int i=0; i<history.size(); i++){
                cout<<history[i]->toString()<<endl;
            }
        }
        else if(opt == 2){
            cout<<"How many days in the future do you want to see"<<endl;
            string number;
            getline(cin,number);
            //Get the future prices
            int numberOfDays = atoi(number.c_str());
            
            vector<double> futurePrices = center->getFuturePrices(validSymbol, numberOfDays);
            cout<<"Future price is "<<endl;
            for(int i=0; i<numberOfDays; i++){
                cout<<futurePrices[i]<<endl;
            }
        }
        else if(opt == 3){
            cout<<"How many days in the future do you want to see"<<endl;
            string number;
            getline(cin,number);
            //Get the future <time,price> pairs
            int numberOfDays = atoi(number.c_str());
            vector<Pair*> future = center->getFuturePricesTable(validSymbol, numberOfDays);
            for(int i=0; i<numberOfDays; i++){
                Pair* pair = future[i];
                cout<<pair->getTime()<<" "<<pair->getPrice()<<endl;
            }
        }
        else if(opt == 4){
            //Get the suggestion
            cout<<center->getTradeSuggestion(validSymbol)<<endl;
        }
        else{
            cout<<"Invalid input"<<endl;
        }
    }
    return 0;
}
开发者ID:YingChen,项目名称:Stock-Analysis-Tool,代码行数:101,代码来源:main.cpp


注:本文中的Pair::getTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。