Пример #1
0
void MainWindow::on_text_nextButton_clicked(){
    if(m_questionList.testAnswer(ui->text_lineEdit->text().toStdString())){
        m_questionList.advance();
        update();
    } else {
        incorrect();
    }
    ui->text_lineEdit->clear();
}
Пример #2
0
void testBug(void)
{
#ifdef SDCC
	REG_1 = 0x40;
	incorrect();
	ASSERT (REG_1 == 0x43);
#endif
	REG_2 = 0x50;
	correct();
	ASSERT (REG_2 == 0x53);
}
Пример #3
0
void MainWindow::on_check_nextButton_clicked(){
    std::string answer="";
    for(auto i: {ui->check_1, ui->check_2, ui->check_3, ui->check_4}){
        answer+=(i->checkState()==Qt::Checked)?"1":"0";
    }
    if(m_questionList.testAnswer(answer)){
        m_questionList.advance();
        update();
    } else {
        incorrect();
    }
    for(auto i: {ui->check_1, ui->check_2, ui->check_3, ui->check_4}){
        i->setChecked(false);
    }
}
Пример #4
0
// simplified disassembled pseudo code for main
int main(void) {

	// Initialize everything needed.
	short serial_1;
	short serial_2;
	short serial_3;
	short serial_4;
	char *name;
	
	// Read name.
	puts("Enter your name (First Last): ");
	gets(name);
	
	// Convert name to lowercase.
	for (i = 0; i < strlen(name); i++) {
		if ((name[i] >= 'A') && (name[i] <= 'Z')) {
			name[i] += 'a' - 'A';
		}
	}
	
	// Prompt for serial number.
	putchar('\n');
	puts("Enter your product's serial number: ");
	puts("(The serial number can be found on the back of the box, e.g. XXXX-XXXX-XXXX-XXXX)");
	scanf("%04x-%04x-%04x-%04x", &serial_1, &serial_2, &serial_3, &serial_4);
	putchar('\n');
	
	// test_key() is the key point to this program, if this function returns 0 then the validation fails.
	// We need to analyze function test_key() to avoid it from returning 0.
	eax = test_key(name, serial_1, serial_2, serial_3, serial_4);
	
	if (eax != 0) {
		// This method simply prints "Key accepted."
		correct(STK-1);
	} else {
	    // This method simply prints "Invalid key."
		incorrect(STK-1);
	}
	
	return 0;
}
Пример #5
0
//******************************************************************************************
//main program function
//******************************************************************************************
void main(void) {
	Sys_Init();      			// System Initialization
	Port_Init();     			// Initialize ports 2 and 3
	Interrupt_Init();			//Initialize Interrupts
	Timer_Init();				//Initialize timer 0
	putchar(' ');    		
	printf("\r\nStart\r\n");
	while(1) {	
		BILED0=1;	//Turn OFF the BILED
		BILED1=1;
		printf("\rHow To Play:\r\nIf Red Led is on the player must Push button 0\r\nIf Green Led is on the player must Push button 1\r\nIf both Leds are on the player must push both Buttons\r\nKeep in mind you will only have 1 sec push the corresponding button/s\r\nA correct input will make the Clear Led flash green, while an incorrect input will make it flash red\r\nTo begin press any key\r\n");	

		keyinput=getchar();
		
		previousnum=keyinput%3;
		i=0;
		numC=0;
		while (i<=9) {
			StopAndResetTimer();
			if(!SS) {
				StartTimer();
				randomnum = random();					//create a random number. where randomnum is a 
				while (randomnum==previousnum) {
					randomnum = random();
				}							//check to see if the random number was used before
	
				if (randomnum==0) {						
					LED0=0;					//turn it on
					debounce(); 			
					LED0=1; 				//turn it off
					if (PB0==0 && PB1==1) {
						correct();		//store correct answer;
					} else {
						incorrect();
					}
				} else if (randomnum==1) {						
					LED1=0; 				//turn it on
					debounce(); 			
					LED1=1; 				//turn it off
					if (PB0==1 && PB1==0) {
						correct();
					} else {
						incorrect();
					}	
				} else{						//rand num is 2, light LED0 and LED1 for 1 second
					LED0=0;
					LED1=0;
					debounce();
					LED0=1;
					LED1=1;
					if (PB0==0 && PB1==0){
						correct();
					} else 	{
						incorrect();
					}
				}
				
				previousnum=randomnum;
				i++;									//increment i
			} else 	{
				PauseTimer();
			}

		}// end while < 9
		printf("\r\n Number of correct answers = %d\r\n", numC);		//display results
		ending();
		TR0 = 0;								//turn off timer
		BILED1=1;
		BILED0=1;
		while (!SS);							//wait until the switch is turned off and back on again to loop
		while (SS);								
	}	
}//end main
Пример #6
0
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),contactModel(parent)
{

  QWidget *centralWidget = new QWidget(this);
  setCentralWidget(centralWidget);
  createActions();

  createMenus();
  const QString mainQmlApp = QLatin1String("qrc:///qml/main.qml");
  view =new QDeclarativeView(this);
  view->rootContext()->setContextProperty("Main", this);
  view->rootContext()->setContextProperty("contactModel", &contactModel);

  view->setSource(QUrl(mainQmlApp));
  // view->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
  view->engine()->addImportPath(QString("/opt/qtm12/imports"));
  view->engine()->addPluginPath(QString("/opt/qtm12/plugins"));

  /*test*/

  //  QSharedPointer<Contact> co = QSharedPointer<Contact>(new Contact("piter88", "Petja"));
  //  co->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0, 59.938994,30.315857, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime())));
  //  contactModel.addContact(co);

  //  QSharedPointer<Contact> con = QSharedPointer<Contact>(new Contact("marja", "Mother"));
  //  con->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0,59.925657,30.296165, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime().addSecs(-3800))));
  //  contactModel.addContact(con);

  //  QSharedPointer<Contact> contact = QSharedPointer<Contact>(new Contact("vred", "Vasja"));
  //  contact->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0,59.945152,31.371842, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime().addSecs(-9600))));
  //  contactModel.addContact(contact);
  //  QSharedPointer<Contact> cont= QSharedPointer<Contact>(new Contact("quen", "daughter"));
  //  cont->setLastDataMark(QSharedPointer<DataMark>(new DataMark(0,59.94376,30.368825, "QString label",
  //                                                                 "QString description", "QString url", QDateTime::currentDateTime())));
  //  contactModel.addContact(cont);

  /*test*/

  client =new Client(&contactModel, this);
  //   view->rootContext()->setContextProperty("Client", client);

  //qmlRegisterType<ContactModel>();

  QObject* rootObject = dynamic_cast<QObject*>(view->rootObject());
  QObject::connect(authAction, SIGNAL(triggered()), rootObject, SLOT(showLoginView()));
  QObject::connect(client, SIGNAL(error(QVariant)), rootObject, SLOT(incorrect(QVariant)));
  QObject::connect(client, SIGNAL(authentificated(QVariant)), rootObject, SLOT(entered(QVariant)));

  QObject::connect(trackingAction, SIGNAL(triggered()), rootObject, SLOT(showTrackSettings()));
  connect(client, SIGNAL(registrationRequestConfirm()),rootObject,SLOT(showNotify()));

  #if defined(Q_WS_MAEMO_5)
  view->setGeometry(QRect(0,0,800,480));
  view->showFullScreen();
  #elif defined(Q_WS_S60)
  view->setGeometry(QRect(0,0,640,360));
  view->showFullScreen();
  #else
  view->setGeometry(QRect(100,100,800, 480));
  view->show();
  #endif
  QVBoxLayout *mainLayout = new QVBoxLayout();
  mainLayout->addWidget(view);
  centralWidget->setLayout(mainLayout);

}
Пример #7
0
void Joueur::choisirCase(int &ligne, int &colonne, Plateau &plateau) {

    do {
        saisir(ligne, colonne);
    } while (!incorrect(ligne, colonne, plateau));
}