本文整理汇总了C++中Number::getNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::getNum方法的具体用法?C++ Number::getNum怎么用?C++ Number::getNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::getNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool operator <(const Number&nl,const Number&nr)
{
return nl.getNum()<nr.getNum();
}
示例2: createNumber
//===================================
//Create new Number in case that all
//conditions are fulfilled
//===================================
void screenMatrix::createNumber(int currentLevel){
int triesCounter = 0;
bool isSuccess = false;
int num;
if (currentLevel<=11)
num = rand() % (10 + currentLevel) + 1;
else
num = rand() % 21 + 1;
if (num < 10)
{
while (isSuccess == false && triesCounter < 10)
{
Point numPosition;
if (numPosition.x != p1.getPosition().x && numPosition.y != p1.getPosition().y
&& numPosition.x != p2.getPosition().x && numPosition.y != p2.getPosition().y
&& matrix[numPosition.y][numPosition.x] == NULL
&& matrix[numPosition.y + 1][numPosition.x] == NULL && matrix[numPosition.y][numPosition.x + 1] == NULL
&& matrix[numPosition.y - 1][numPosition.x] == NULL && matrix[numPosition.y][numPosition.x - 1] == NULL)
{
Number *newOne = new Number;
newOne->setIsOnes(false);
newOne->setIsTens(false);
newOne->setNum(num);
newOne->setNumberPosition(numPosition);
matrix[numPosition.y][numPosition.x]=newOne;
isSuccess = true;
if (isSuccess==true){
gotoxy(numPosition.x,numPosition.y);
cout<<newOne->getNum();
// +++++++++++++++++++++++++++++++++++++++++++++++++
// "NEW CODE EX3, author=Dror Moyal, date=2015-06-02
// +++++++++++++++++++++++++++++++++++++++++++++++++
numList.insertToTail(newOne);
nodeMatrix[numPosition.y][numPosition.x] = numList.getTail();
//+++++++++++++++++++++
// END of NEW CODE EX3
//+++++++++++++++++++++
}
}
else
++triesCounter;
}
}
else if (num >= 10)
{
while (isSuccess == false && triesCounter < 10)
{
Point tensPosition;
Point onesPosition(tensPosition.x + 1, tensPosition.y);
if ((tensPosition.x != p1.getPosition().x && tensPosition.y != p1.getPosition().y
&& tensPosition.x != p2.getPosition().x && tensPosition.y != p2.getPosition().y
&& matrix[tensPosition.y][tensPosition.x] == NULL
&& matrix[tensPosition.y + 1][tensPosition.x] == NULL && matrix[tensPosition.y][tensPosition.x + 1] == NULL
&& matrix[tensPosition.y - 1][tensPosition.x] == NULL && matrix[tensPosition.y][tensPosition.x - 1] == NULL)
&&
(onesPosition.x != p1.getPosition().x && onesPosition.y != p1.getPosition().y
&& onesPosition.x != p2.getPosition().x && onesPosition.y != p2.getPosition().y
&& matrix[onesPosition.y][onesPosition.x] == NULL
&& matrix[onesPosition.y + 1][onesPosition.x] == NULL && matrix[onesPosition.y][onesPosition.x + 1] == NULL
&& matrix[onesPosition.y - 1][onesPosition.x] == NULL && matrix[onesPosition.y][onesPosition.x - 1] == NULL)
&& onesPosition.x <= onesPosition.maxX)
{
Number *newTens = new Number;
Number *newOnes = new Number;
newTens->setIsTens(true);
newTens->setIsOnes(false);
newTens->setNum(num/10);
newTens->setNumberPosition(tensPosition);
newOnes->setIsOnes(true);
newOnes->setIsTens(false);
newOnes->setNum(num % 10);
newOnes->setNumberPosition(onesPosition);
matrix[tensPosition.y][tensPosition.x]=newTens;
matrix[tensPosition.y][tensPosition.x+1]=newOnes;
isSuccess = true;
if (isSuccess==true){
gotoxy(tensPosition.x,tensPosition.y);
cout<<newTens->getNum()<<newOnes->getNum();
// +++++++++++++++++++++++++++++++++++++++++++++++++
// "NEW CODE EX3, author=Dror Moyal, date=2015-06-02
// +++++++++++++++++++++++++++++++++++++++++++++++++
numList.insertToTail(newTens);
nodeMatrix[tensPosition.y][tensPosition.x] = numList.getTail();
numList.insertToTail(newOnes);
nodeMatrix[tensPosition.y][tensPosition.x+1] = numList.getTail();
//+++++++++++++++++++++
// END of NEW CODE EX3
//+++++++++++++++++++++
}
}
//.........这里部分代码省略.........