コード例 #1
0
ファイル: griditem.cpp プロジェクト: FlorinLozneanu/lines
/*!
*/
BallItem* GridItem::hideBall(BallItem *ball)
{
    if (!ball) {
        qDebug() << "GridItem::hideBall(BallItem *): pointer to the ball item is NULL";
        return 0;
    }

    ball->setVisible(false);
    // changes used position to an available one
    BallItemsProvider::instance()->fromUsedToAvailable(ball->coordinates());
    //

    freePos(ball->coordinates());
    return ball;
}
コード例 #2
0
ファイル: griditem.cpp プロジェクト: FlorinLozneanu/lines
/*!
*/
void GridItem::moveBall(BallItem *ball, const QVector<GridPos> &path)
{
    if (!ball) {
        qDebug() << "GridItem::moveBall(...): pointer to the ball item is NULL";
        return;
    }

    QVector<GridPos> tmpPath(path);

    // skip the first square
    GridPos firstPos = tmpPath.front();
    freePos(firstPos);
    //

    // the source square becomes available
    BallItemsProvider::instance()->fromUsedToAvailable(firstPos);
    //

    QGraphicsScene *theScene = scene();
    Q_ASSERT(theScene);
    Q_ASSERT(theScene->views().isEmpty() == false);

    theScene->views()[0]->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
    foreach(GridPos pos, tmpPath) {
        if (pos != tmpPath.back()) {
            // do not store the ball item on the positions of the intermediate squares (the 3rd argument
            // is set to false).
            showBall(ball, pos, false);
            pause(100);
        } else {
            // is there any hint ball onto the target square ?
            BallItem *hintBall = ballAt(pos);
            if (hintBall) {
                hideBall(hintBall);
                delete hintBall;

                BallItemsProvider::instance()->removeHint(hintBall);
            }

            // stores the ball item on the position of the target square.
            showBall(ball, pos, true);
        }
        // also wipes the path tracks square by square
        m_pathTracker.removeFrontLine();
        update();
    }
}
コード例 #3
0
ファイル: main.c プロジェクト: amstl14/CS2050-Lab5
int main(int argc,char *argv[]) {
    FILE *fp3;
    char line3[128];
   
    
    if (argc != 4) //ERROR CHECK NUMBER OF ARGS
    {
        printf("\n Babbage USEAGE: <./a.out> <positive.txt> <negative.txt> <review#.txt> \n ");
        printf("\n Netbeans USEAGE: <positive.txt> <negative.txt> <review#.txt> \n ");
        return 0;
    }
    
    LIST1 *current1, *temp;
    LIST2 *temp2;
    current1 = positive_list(argv[1]); //ASSIGN CURRENT1 TO THE POSITIVE LIST

    LIST2 *current2;
    current2 = negative_list(argv[2]); //ASSIGN CURRENT2 TO THE NEGATIVE LIST
    
    if ((fp3 = fopen(argv[3], "r")) == NULL) //ERROR CHECK FILE OPENING
    {
        printf("\nError opening file");
        return 0;
    }
    
    int numPositive = 0, numNegative = 0;
    
    char *token;
    
    printf("\n----------- FOUND WORDS -----------\n\n");
    
    while(!feof(fp3)){
        fscanf(fp3,"%s\n",line3);

        token = strtok(line3," ,.\n");
        
        for(temp = current1; temp ; temp=temp->next){
            
            
            if(strcmp(token,temp->positive) == 0)
            {
                printf("The token \"%s\" was a valid positive word.\n",temp->positive); //PRINT OUT POSITIVE TOKENS
                numPositive++;
            }
            
        }
        
        for(temp2 = current2; temp2 ; temp2=temp2->next){
            
            if(strcmp(token,temp2->negative) == 0)
            {
                printf("The token \"%s\" was a valid negative word.\n",temp2->negative); //PRINT OUT NEGATIVE TOKENS
                numNegative++;
            }
        }
    }
    
    fclose(fp3); //CLOSE FILE
    print(numPositive,numNegative,argv[3]);
    freePos(current1);
    freeNeg(current2);
    
    return 0;
}