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


C++ Computer::getYear方法代码示例

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


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

示例1: Search

void Search( vector<Computer> & list, Computer p ) {        // Search for members in list based on template person p
    vector<Computer> SearchList;                      // Create search result vector

    for( unsigned int x = 0; x < list.size(); x++) {    // Search each entry of list
        bool add = true;                                    // We say the entry should be added by default then exclude it based on the template person
        if( p.getName() != "" )
            if( !list[x].getName().contains( p.getName(), Qt::CaseInsensitive ) )
                add = false;

        if( p.getType() != "" )
            if( !list[x].getType().contains( p.getType() , Qt::CaseInsensitive ) )
                add = false;

        if( p.getWasBuilt() != 2 )
            if( !(list[x].getWasBuilt() == p.getWasBuilt() ) )
                add = false;

        if( p.getYear() != "" )
            if( !(list[x].getYear() == p.getYear() ) )
                add = false;

        if(add)
            SearchList.push_back( list[x] );
    }
    displayComputer( SearchList );              // Display search results
}
开发者ID:Njallzzz,项目名称:Skilaverkefni,代码行数:26,代码来源:menu.cpp

示例2: displayComp

void AddLink::displayComp(vector<Computer>& computer)
{
    ui->table_linking->setSortingEnabled(false);

    ui->table_linking->clearContents();
    ui->table_linking->setColumnCount(5);
    ui->table_linking->setRowCount(computer.size());

    ui->table_linking->setHorizontalHeaderItem(0,new QTableWidgetItem(QString("id")));
    ui->table_linking->setHorizontalHeaderItem(1,new QTableWidgetItem(QString("Name")));
    ui->table_linking->setHorizontalHeaderItem(2,new QTableWidgetItem(QString("Year")));
    ui->table_linking->setHorizontalHeaderItem(3,new QTableWidgetItem(QString("Type")));
    ui->table_linking->setHorizontalHeaderItem(4,new QTableWidgetItem(QString("Built")));

    for(size_t i = 0; i < computer.size(); i++)
    {
        Computer temp = computer[i];

        QTableWidgetItem* id = new QTableWidgetItem;
        id->setData(Qt::DisplayRole,temp.getID());

        ui->table_linking->setItem(i,0, id);
        ui->table_linking->setItem(i,1, new QTableWidgetItem(QString::fromStdString(temp.getName())));
        ui->table_linking->setItem(i,2, new QTableWidgetItem(QString::number(temp.getYear())));
        ui->table_linking->setItem(i,3, new QTableWidgetItem(QString::fromStdString(temp.getType())));
        ui->table_linking->setItem(i,4, new QTableWidgetItem(QString::number(temp.getBuilt())));
    }

    ui->table_linking->setSortingEnabled(true);
}
开发者ID:SenpaiPlz,项目名称:0011Week,代码行数:30,代码来源:addlink.cpp

示例3: addToDatabase

void ComputerRepository::addToDatabase(Computer computer) {
    QSqlQuery query(datab);
    query.prepare("INSERT INTO Computers(Name, Type, WasBuilt, YearBuilt) VALUES (:Name, :Type, :WasBuilt, :YearBuilt)");
    query.bindValue(":Name", QString::fromStdString(computer.getName()));
    query.bindValue(":Type", QString::fromStdString(computer.getType()));
    query.bindValue(":WasBuilt", QString::fromStdString(computer.getWasBuilt()));
    query.bindValue(":YearBuilt", QString::fromStdString(computer.getYear()));
    query.exec();
}
开发者ID:axelboga,项目名称:hopur32,代码行数:9,代码来源:computerrepository.cpp

示例4: addComputer

void Database::addComputer(Computer computer)
{
    QSqlQuery query(connectDatabase());

    query.prepare("INSERT INTO Computers (ComputersName, YearBuilt, Type, WasItBuilt) VALUES (:name, :year, :type, :built)");
    query.bindValue(":name",         QString::fromStdString(computer.getName()));
    query.bindValue(":year",         QString::number(computer.getYear()));
    query.bindValue(":type",         QString::fromStdString(computer.getType()));
    query.bindValue(":built",        QString::number(computer.getwasItBuilt()));
    query.exec();
}
开发者ID:Dagnyb,项目名称:VLN-1,代码行数:11,代码来源:database.cpp

示例5: addEntry

int SQLITEHandler::addEntry( Computer c ) {         // Add Computer to database
    if( !status )                                   // If not connected, fail
        return 1;
    q.prepare( "INSERT INTO computers (name, creation, type, constructed) VALUES (:name, :creation, :type, :constructed)" );
    q.bindValue( ":name", c.getName() );
    q.bindValue( ":creation", c.getYear() );
    q.bindValue( ":type", c.getType() );
    q.bindValue( ":constructed", c.getWasBuilt() );
    if( !q.exec() )                                 // Attempt to execute query
        return 1;
    return 0;                   // Return Success
}
开发者ID:Njallzzz,项目名称:Skilaverkefni,代码行数:12,代码来源:sqlitehandler.cpp

示例6: modifyEntry

int SQLITEHandler::modifyEntry( Computer c ) {      // Modify computer in database
    if( !status )                                   // If not connected, fail
        return 1;
    q.prepare( "UPDATE computers SET name = (:name), creation = (:creation), type = (:type), constructed = (:constructed) WHERE id = (:id)" );
    q.bindValue( ":id", c.getId() );
    q.bindValue( ":name", c.getName() );
    q.bindValue( ":creation", c.getYear() );
    q.bindValue( ":type", c.getType() );
    q.bindValue( ":constructed", c.getWasBuilt() );
    if( !q.exec() )                                 // Attempt to execute query
        return 2;
    return 0;                   // Return Success
}
开发者ID:Njallzzz,项目名称:Skilaverkefni,代码行数:13,代码来源:sqlitehandler.cpp

示例7: displayComputer

void MainWindow::displayComputer(vector<Computer> computers) {
    ui->table_computers->clearContents();
    ui->table_computers->setRowCount(computers.size());

    for (unsigned int i = 0; i < computers.size(); i++) {
        Computer currentComputer = computers.at(i);
        QString Name = QString::fromStdString(currentComputer.getName());
        QString Type = QString::fromStdString(currentComputer.getType());
        QString WasBuilt = QString::fromStdString(currentComputer.getWasBuilt());
        QString Year = QString::fromStdString(currentComputer.getYear());

        ui->table_computers->setItem(i, 0, new QTableWidgetItem(Name));
        ui->table_computers->setItem(i, 1, new QTableWidgetItem(Type));
        ui->table_computers->setItem(i, 2, new QTableWidgetItem(WasBuilt));
        ui->table_computers->setItem(i, 3, new QTableWidgetItem(Year));
    }
    currentlyDisplayedComputers = computers;
}
开发者ID:axelboga,项目名称:hopur32,代码行数:18,代码来源:mainwindow.cpp

示例8: editComputer

bool DbManager::editComputer(Computer comp)
{
    QString was_built = "";
    switch (comp.getBuilt())
    {
    case 0:
        was_built = "0";
        break;
    case 1:
        was_built = "1";
        break;
    }

    return execQuery("UPDATE Computers "
                     "SET name = '" + comp.getName() + "', "
                     "year = " + comp.getYear() + ", "
                     "type = '" + comp.getType() + "', "
                     "built = " + was_built + " "
                     "WHERE cID = " + comp.getId());
}
开发者ID:hrafnkelli14,项目名称:Verklegt-verkefni-2,代码行数:20,代码来源:dbmanager.cpp

示例9: addComputer

bool DbManager::addComputer(Computer comp)
{
    QString was_built = "";
    switch (comp.getBuilt())
    {
    case 0:
        was_built = "0";
        break;
    case 1:
        was_built = "1";
        break;
    }

    return execQuery("INSERT INTO Computers (name, year, type, built) "
                     "VALUES ( '" +
                     comp.getName() + "'," +
                     comp.getYear() + ",'" +
                     comp.getType() + "', " +
                     was_built + " )");
}
开发者ID:hrafnkelli14,项目名称:Verklegt-verkefni-2,代码行数:20,代码来源:dbmanager.cpp

示例10: SearchComputerMenu

Computer SearchComputerMenu() {
    Computer temp;    char key = 0;   QTextStream in(stdin);
    temp.setName("");
    temp.setType("");
    temp.setWasBuilt(2);
    while( key != '5' ) {           // while looping while inserting search parameters
        cout << "Please specify search parameters" << endl;
        cout << "\t1. Search by name(";
        if( temp.getName() == "" )               // If wildcard
            cout << "any)" << endl;
        else                                // if user specified
            cout << temp.getName().toUtf8().constData() << ")" << endl;     // Write current name parameters

        cout << "\t2. Search by type(";
        if( temp.getType() == "" )              // If wildcard
            cout << "any)" << endl;
        else
            cout << temp.getType().toUtf8().constData() << ")" << endl;     // Write current type parameters

        cout << "\t3. Search by built(";
        if( temp.getWasBuilt() == 2 )         // If wildcard
            cout << "any)" << endl;
        else if( temp.getWasBuilt() == 0 )                               // if user specified
            cout << "not built)" << endl;  // Write current birth parameters
        else if( temp.getWasBuilt() == 1 )
            cout << "built)" << endl;  // Write current birth parameters

        cout << "\t4. Search by year(";
        if( temp.getYear() == "" )         // If wildcard
            cout << "any)" << endl;
        else                                // if user specified
            cout << temp.getYear().toUtf8().constData() << ")" << endl;  // Write current death parameters
        cout << "\t5. Search" << endl;

        cout << "Your choice: ";
        cin >> key;                 // Get user input for next action, 1: name parameter, 2: gender parameter, 3: birth parameter, 4: death parameter and 5: Search
        cin.ignore();

        if( key == '1' ) {          // Set user name search parameter
            cout << "Insert name to search for: ";
            temp.setName( in.readLine() );
        } else if( key == '2' ) {   // Set user type search parameter
            cout << "Insert type to search for: ";
            temp.setType( in.readLine() );
        } else if( key == '3' ) {   // Set user birth search parameter
            temp.setWasBuilt( -1 );
            while( (temp.getWasBuilt() < 0) || (temp.getWasBuilt() > 2) ) {
                QString built;
                cout << "Insert built or not to search for(any/built/not built): ";
                built = in.readLine();
                if( built == "any" || built == "Any" )
                    temp.setWasBuilt( 2 );
                else if( built == "not built" || built == "Not built" || built == "not Built" || built == "Not Built" )
                    temp.setWasBuilt( 0 );
                else if( built == "built" || built == "Built" )
                    temp.setWasBuilt( 1 );
                else
                    cout << "Invalid input!" << endl;
            }
        } else if( key == '4' ) {   // Set user death search parameter
            QString deathstring = "";
            temp.setYear( "" );   // Set empty date (Also used as wildcard)
            while( deathstring != "0" && temp.getYear() == "" ) {
                cout << "Insert death date(dd.mm.yyyy, 0 for any): ";
                deathstring = in.readLine();
                if( deathstring != "0" )
                    temp.setYear( deathstring );
            }
        }
    }
    cout << endl;
    return temp;        // Returns template for person to search for
}
开发者ID:Njallzzz,项目名称:Skilaverkefni,代码行数:73,代码来源:menu.cpp


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