本文整理汇总了C++中Number::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::getValue方法的具体用法?C++ Number::getValue怎么用?C++ Number::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::getValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushNumber
void Gameplay::pushNumber(const Number &n, bool pushToVec = true) {
if (pushToVec) {
numbers.push_back(n);
}
for (int i = sumOfNumbers; i >= 0; i--)
if (reachable[i]) {
reachable[i + n.getValue()] = true;
}
sumOfNumbers += n.getValue();
correctSum = findCorrectSum();
}
示例2: cMemento
void BehaviourPatterns::cMemento() {
int i;
cout << "Integer: ";
cin >> i;
Number* object = new Number( i );
CommandM* commands[3];
commands[1] = new CommandM( object, &Number::dubble );
commands[2] = new CommandM( object, &Number::half );
cout << "Exit[0], Double[1], Half[2], Undo[3], Redo[4]: ";
cin >> i;
while( i ) {
if( i == 3 ) {
CommandM::undo();
}
else if( i == 4 )
CommandM::redo();
else
commands[i]->execute();
cout << " " << object->getValue() << endl;
cout << "Exit[0], Double[1], Half[2], Undo[3], Redo[4]: ";
cin >> i;
}
}
示例3: main
int main()
{
int i;
cout << "Integer: ";
cin >> i;
Number *object = new Number(i);
Command *commands[3];
commands[1] = new Command(object, &Number::dubble);
commands[2] = new Command(object, &Number::half);
cout << "Exit[0], Double[1], Half[2], Undo[3], Redo[4]: ";
cin >> i;
while (i)
{
if (i == 3)
Command::undo();
else if (i == 4)
Command::redo();
else
commands[i]->execute();
cout << " " << object->getValue() << endl;
cout << "Exit[0], Double[1], Half[2], Undo[3], Redo[4]: ";
cin >> i;
}
}
开发者ID:Capibara-,项目名称:tau-cs-spring-2010-advanced-topics-in-programming-ariel-shay,代码行数:27,代码来源:BP_Memento.cpp
示例4: main
int main()
{
int i;
cout << "Please enter an integer: ";
cin >> i;
Number * object = new Number(i);
Command * commands[5];
commands[1] = new Command(object, &Number::doubleValue);
commands[2] = new Command(object, &Number::halfValue);
commands[3] = new Command(object, &Number::increaseByOne);
commands[4] = new Command(object, &Number::decreaseByOne);
cout << "[0]Exit, [1]Double, [2]Half, [3]Increase, [4]Decrease, [5]Undo, [6]Redo: ";
cin >> i;
while (i != Command::Operation::Exit)
{
if (i == Command::Operation::Undo)
{
Command::undo();
}
else if (i == Command::Operation::Redo)
{
Command::redo();
}
else if (i > Command::Operation::Exit && i < Command::Operation::Undo)
{
commands[i]->execute();
}
else
{
cout << "Enter a proper choice: ";
cin >> i;
continue;
}
cout << " " << object->getValue() << " " << object->getName() << " " << object->getDecimal() << endl;
cout << "[0]Exit, [1]Double, [2]Half, [3]Increase, [4]Decrease, [5]Undo, [6]Redo: ";
cin >> i;
}
}
示例5: operator
void Printer::operator()(const SmartPointer<Block> &block) {
if (!block->isEmpty() || !removeBlankLines) {
if (addComments) {
string comments;
Block::const_iterator it;
for (it = block->begin(); it != block->end(); it++) {
Word *word = dynamic_cast<Word *>(it->get());
if (word) {
char type = word->getType();
Number *number = dynamic_cast<Number *>(word->getExpression().get());
if (number) {
double value = number->getValue();
const Code *code = Codes::find(type, value);
if (code) comments += SSTR(" (" << code->description << ')');
}
}
}
if (!comments.empty()) {
string line = SSTR(*block);
stream << line;
int pad = 80 - (line.length() + comments.length());
if (0 < pad) stream << string(pad, ' ');
stream << comments << '\n';
return;
}
}
stream << *block << '\n';
}
}
示例6: eval
double Evaluator::eval(Number &e) {
return e.getValue();
}
示例7:
long operator-(long val, const Number &num)
{
return num.getValue() - val;
}
示例8: getValue
int Number::operator>=(const Number &num)
{
return getValue() >= num.getValue();
}
示例9: Number
Number operator+ (const Number& lv,const Number& rv){
string lvs = lv.getValue();
int lv_length = lvs.size();
string rvs = rv.getValue();
int rv_length = rvs.size();
unsigned short int flag(0); //进位
char result[202];
char temp[202];
unsigned short int res;
string max_length_str;
string min_length_str;
int min_length;
int length;
if(lv_length>rv_length){
length = lv_length;
min_length = rv_length;
max_length_str = lvs;
min_length_str = rvs;
}else{
length = rv_length;
min_length = lv_length;
max_length_str = rvs;
min_length_str = lvs;
}
strcpy(result,max_length_str.c_str());
strcpy(temp+(length-min_length),min_length_str.c_str());
for(int i=length-1,j=0;i>=0;i--,j++){
if(i == length-3){
result[i] = '.';
continue;
}
if(j< min_length){
res = (unsigned short int)result[i]-48 + (unsigned short int)temp[i]-48+flag;
if(res>=10){flag = 1;res-=10;}else{flag = 0;}
// cout<<res<<endl;
result[i] = res+48;
}else{
if(flag>0){
unsigned short int tem = (unsigned short int)result[i]-48 + flag;
if(tem>10){
flag = 1;
tem-=10;
}else{
flag = 0;
}
result[i] = tem+48;
}else{
break;
}
}
}
char sum_number[202];
if(flag>0){
sum_number[0] = '1';
strcpy(sum_number+1,result);
return Number(sum_number);
}else{
return Number(result);
}
}