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