本文整理汇总了C++中Computer类的典型用法代码示例。如果您正苦于以下问题:C++ Computer类的具体用法?C++ Computer怎么用?C++ Computer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Computer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildGamingComputerTest3
bool buildGamingComputerTest3()
{
ComputerBuilder *builder = new GamingComputerBuilder();
builder->createComputer();
Computer *computer = builder->getResult();
Part** list = computer->getAdditionalPartsList();
for (int i = 0; i < computer->getNumberOfAdditionalParts(); ++i)
{
Part* part = list[i];
if (part != 0)
{
// tests if Part is a BluRay drive
if(dynamic_cast<BluRayDrive*>(part))
{
delete builder;
delete computer;
return true;
}
}
}
delete builder;
delete computer;
return false;
}
示例2: buildGamingComputerTest2
bool buildGamingComputerTest2()
{
ComputerBuilder *builder = new GamingComputerBuilder();
builder->createComputer();
Computer *computer = builder->getResult();
Ram* ram = computer->getRamSet().getRamSticks();
int amountOfRam = 0;
for (int i = 0; i < computer->getRamSet().getNumberOfRamSticks(); ++i)
{
amountOfRam += ram[i].getRamSize();
}
if (amountOfRam >= 16)
{
delete builder;
delete computer;
return true;
}
delete builder;
delete computer;
return false;
}
示例3: main
int main()
{
// unit_test();
auto instructionsInText = readStrings(INPUT_FILE);
auto program = parseInstructions(instructionsInText);
Computer c;
c.program = program;
// Part1
{
c.reset();
c.start();
auto regA = c.registers.registerValues[0];
cout << "Day 12 part 1 answer: " << regA << endl;
}
// Part 2
{
c.reset();
c.registers.registerValues[2 /* c */] = 1;
c.start();
auto regA = c.registers.registerValues[0];
cout << "Day 12 part 2 answer: " << regA << endl;
}
return 0;
}
示例4: dealDeck
void dealDeck(Player& user, Computer& comp, Cards& deck, int count)
{
if (count % EVEN_ODD == EMPTY) // Deal to user first
{
unsigned int i = EMPTY;
while (i < EVEN_ODD*CARDS_DEALT)
{
user.InsertIntoHand(deck.TopDeckCard());
deck.PopOffCard();
i++;
comp.InsertIntoHand(deck.TopDeckCard());
deck.PopOffCard();
i++;
}
deck.AdjustPickPile();
} else // Deal to computer first
{
unsigned int j = EMPTY;
while (j < EVEN_ODD*CARDS_DEALT)
{
comp.InsertIntoHand(deck.TopDeckCard());
deck.PopOffCard();
j++;
user.InsertIntoHand(deck.TopDeckCard());
deck.PopOffCard();
j++;
}
deck.AdjustPickPile();
}
}
示例5: buildOfficeComputerTest1
bool buildOfficeComputerTest1()
{
ComputerBuilder *builder = new OfficeComputerBuilder();
builder->createComputer();
Computer *computer = builder->getResult();
delete builder;
std::string actual = computer->getComputerSpecifications();
std::string expected = "Office Computer\n";
expected += "CPU: Intel Celeron G1610 Ivy Bridge Dual-Core, Clock Speed: 2.6 Ghz, Socket: LGA 1155\n";
expected += "Motherboard: ASUS P8H61-M LE/CSM R2.0, Socket: LGA 1155\n";
expected += "No. of Ram Slots: 2, No. of Graphics Cards Permitted: 1\n";
expected += "Ram: Number Of Sticks: 2\n";
expected += "Slot 1: CORSAIR Vengeance, Frequency: 1600 Mhz, Size: 4 GB\n";
expected += "Slot 2: CORSAIR Vengeance, Frequency: 1600 Mhz, Size: 4 GB\n";
expected += "Hard Drives: Number Of Drives: 1\n";
expected += "Drive 1: Western Digital Blue WD5000AAKX, Size: 500 GB, 7200 RPM\n";
expected += "Graphics Cards: Number Of Cards: 1\n";
expected += "Slot 1: On board graphics, Frequency: 650 Mhz, Size: 1 GB\n";
expected += "Case: Corsair Obsidian 750D Black Aluminum, Case Type: BaseUnit\n";
expected += "Power Supply: Be Quiet! Power Zone, Maximum Power: 650 Watts\n";
expected += "Additional Parts\n";
expected += "DVD Drive: ASUS 24X DVD Burner, Read Speed: 24X";
delete computer;
return actual == expected;
}
示例6: func
void func(chessboard *chess, int depth,int turn,Vector2i* bestmove,Vector2i start,Vector2i end)
{
Computer temp;
if(turn==2) //If the computer is playing for player 2 then calling minSearch and trying to find largest value of board for each value returned by minsearch
{
int value = temp.minSearch( depth-1 , *chess ,-INFINITY,INFINITY); //Finding all the minimum values of board
if( value > bestvalue ) //Selecting the best move by finding the maximum of the values obtained
{
bestvalue = value;
bestmove[0].x = start.x;
bestmove[0].y = start.y;
bestmove[1].x = end.x;
bestmove[1].y = end.y;
}
}
else //Opposite of that for player 1
{
int value = temp.maxSearch( depth-1 , *chess,-INFINITY,INFINITY ); //Finds all maximum values of board
if( value < bestvalue ) //Selects the lowest of those values
{
bestvalue = value;
bestmove[0].x = start.x;
bestmove[0].y = start.y;
bestmove[1].x = end.x;
bestmove[1].y = end.y;
}
}
delete chess; //Chess board obtained is deleted as no longer needed
}
示例7: ScoreOutput
void ScoreOutput(Player& user, Computer& comp, int roundCount)
{
cout << "After " << roundCount << " rounds:\n" <<
"Your current score: " << user.GetScore() << "\n" <<
comp.GetName() << "'s current score: " << comp.GetScore() << "\n" <<
"And the game continues...\n\n";
}
示例8: main
int main() {
Computer A;
A.input();
Computer B = A;
A.display();
B.display();
}
示例9: nextPlayer
void Model::nextPlayer() {
this->incrementActivePlayerId();
Player* player = this->activePlayer();
this->notify();
// check if this player has any cards to play
// if not, end the turn and notify
if (player->hand().size() == 0) {
std::cerr << "Setting round to ended" << std::endl;
this->roundEnded_ = true;
std::cerr << "Notifying user" << std::endl;
this->notify();
if (!this->hasWinner()) {
std::cerr << "Game didn't have a winner, so we start another round" << std::endl;
this->startRound();
} else {
std::cerr << "Game had a winner" << std::endl;
this->endGame();
}
std::cerr << "Updating the view after either starting another round or ending the game" << std::endl;
return;
}
if (player->type() == "Computer") {
Computer* computer = (Computer*)player;
Card* card = computer->play(this->legalPlaysInHand(computer->hand()));
if (card != NULL) {
this->cardsOnTable_[card->getSuit()][card->getRank()] = card;
}
this->notify();
this->nextPlayer();
}
}
示例10: main
int main()
{
Computer compute;
compute.setSpeed(100);
cout << compute.readSpeed() << endl;
}
示例11: buildGamingComputerTest1
bool buildGamingComputerTest1()
{
ComputerBuilder *builder = new GamingComputerBuilder();
builder->createComputer();
Computer *computer = builder->getResult();
HardDrive** hardDrives = computer->getHardDriveSet().getHardDrives();
int hardDriveSpace = 0;
for (int i = 0; i < computer->getHardDriveSet().getNumberOfHardDrives(); ++i)
{
hardDriveSpace += hardDrives[i]->getHardDriveSize();
}
if (hardDriveSpace >= 5000)
{
delete builder;
delete computer;
return true;
}
delete builder;
delete computer;
return false;
}
示例12: createProduct
Computer* createProduct(int tipo) {
Computer* myComputer = factoryMethod(tipo);
myComputer->componentSelection();
myComputer->componentEnsambling();
myComputer->SWInstalation();
myComputer->computerPacking();
return myComputer;
}
示例13: displayComputersForScientistConnections
void MainWindow::displayComputersForScientistConnections(vector<Computer> computers) {
ui->computer_list_scientist_connections->clear();
for (unsigned int i = 0; i < computers.size(); i++) {
Computer currentComputer = computers.at(i);
QString name = QString::fromStdString(currentComputer.getName());
ui->computer_list_scientist_connections->addItem(name);
}
}
示例14: main
int main()
{
Computer computer;
ComputerPartDisplayVoistor visitor;
computer.accept(&visitor);
cout << "Hello World!" << endl;
return 0;
}
示例15: computerCPUTest
bool computerCPUTest()
{
Computer* computer = new Computer();
computer->setCPU(CPU("Intel Core i7-3770K Ivy Bridge Quad-Core", 3.5, "LGA 1155"));
std::string expected = "CPU: Intel Core i7-3770K Ivy Bridge Quad-Core, Clock Speed: 3.5 Ghz, Socket: LGA 1155";
std::string actual = std::string(computer->getCPU().getPartInformation());
delete computer;
return expected == actual;
}