Пример #1
0
int main()
{

   Adventure object;//object is the one for activityclass
   cout<<"Welcome new user!please follow the command as given"<<endl;
   cout<<"This program can help you to store/display the information of the stored activities"<<endl;
   do{//the do while loop so the user can choose to quit or continue.


      do
      {
	 object.insert();//for user to input their data
      }while ( again()==true);   //the loop will stop if user want to 
     
      
      cout<<"Do you want to display all the information?(Y/N)"<<endl;
      char answer;//so answer if the user want to display the info
      cin>>answer;
      cin.ignore(100,'\n');
      answer = toupper (answer);
      if (answer == 'Y')//if user input y, the loop will display all the informatioon from the display function
	object.displaylll();//display all the information about stored data.

      char season[50];//season, to get the user picked season
      cout<<"Please enter the activity season you'd like to check: ";
      cin.get(season,50,'\n');
      object.displayseasonlll(season);//so if the season matches, display the activity info.
     

   }while (again()==true);

   return 0;
}
	void timer::handler(const boost::system::error_code& aError)
	{
		bool ok = !aError && enabled();
		if (ok && iInReady && !waiting())
		{
			again();
			return;
		}
		iWaiting = false;
		if (ok)
		{
			try
			{
				iInReady = true;
				neolib::lifetime::destroyed_flag destroyed{ *this };
				if (std::uncaught_exceptions() == 0)
					ready();
				else
					again();
				if (destroyed)
					return;
				iInReady = false;
			}
			catch (...)
			{
				iInReady = false;
				throw;
			}
		}
	}
Пример #3
0
void Timer::restart()
{
    // STrace, "Restarting: ", __handle.ptr)
    if (!active())
        return start(); //_timeout, _interval);
    return again();
}
Пример #4
0
void again()
{
    nodelay(stdscr,0);
    clear();
    mvprintw(0,0,"You made it to level %d with %d flags.\nPlay again?(YN)", lv,score);
    refresh();
    switch (getch())
    {
    case 'Y':
    case'y':
        lv=0;
        life=LIVES;
        px=XSIZE/2;
        score=0;
        chance=CHANCE;
        fchance=FCHANCE;
        empty();
        clear();
        newlev();
        play();
        break;
    case 'N':
    case'n':
        exit(endwin());
    default:
        again();
    }
}
/*private virtual*/  void CDelayedOp::RunL()
    {
    __LOG_ENTER_SUPPRESS( "Run" );
    TBool again( EFalse );
    
    TRAPD( err, again = ExecuteOpL() );
    
    if ( KErrNone != err )
        {
        __LOG_WRITE8_FORMAT1_INFO(
            "Error while executing delayed operation: %d.", err );
        }
    
    if ( again )
        {
        StartOp();
        }
    else
        {
        //self-destroy.
        iManager->DequeueOp( *this );
//<qmail>		
		    //Remove this from iDelayedOpReqs as well.
	    for ( TInt i = 0; i < iPlugin->iDelayedOpReqs.Count(); i++ )
	        {
	        if ( iPlugin->iDelayedOpReqs[i] == this )
	            {
	            iPlugin->iDelayedOpReqs.Remove( i );
	            break;
	            }
	        }
//</qmail>			
        delete this;
        }
    }
TEST(CustomElementDescriptorTest, equal)
{
    CustomElementDescriptor myTypeExtension("my-button", "button");
    CustomElementDescriptor again("my-button", "button");
    EXPECT_TRUE(myTypeExtension == again)
        << "two descriptors with the same name and local name should be equal";
}
		timer& operator=(const timer& aOther)
		{
			if (waiting())
				cancel();
			if (aOther.waiting())
				again();
			return *this;
		}
	void timer::enable(bool aWait)
	{
		if (iEnabled)
			throw already_enabled();
		iEnabled = true;
		if (aWait)
			again();
	}
		void set_duration(uint32_t aDuration_ms, bool aEffectiveImmediately = false)
		{
			iDuration_ms = aDuration_ms;
			if (aEffectiveImmediately && waiting())
			{
				cancel();
				again();
			}
		}
Пример #10
0
bool RdfDB::loadData (BasicGraphPattern* target, IStreamContext& istrP, std::string nameStr, std::string baseURI, POSFactory* posFactory, NamespaceMap* nsMap) {
    w3c_sw::StreamRewinder rb(*istrP);
    io::stream_buffer<w3c_sw::StreamRewinder::Device> srsb(rb.device); // ## debug with small buffer size, e.g. 4
    std::istream is(&srsb);
    IStreamContext istr(istrP.nameStr, is,
                        istrP.mediaType.is_initialized() ? istrP.mediaType.get().c_str() : NULL);
    try {
        if (istr.mediaType.match("text/html") ||
                istr.mediaType.match("application/xhtml")) {
            if (xmlParser == NULL)
                throw std::string("no XML parser to parse ")
                + istr.mediaType.toString()
                + " document " + nameStr;
            RDFaParser parser(nameStr, posFactory, xmlParser);
            if (baseURI != "")
                parser.setBase(baseURI);
            if (nsMap != NULL)
                parser.setNamespaceMap(nsMap);
            return parser.parse(target, istr);
        } else if (istr.mediaType.match("text/rdf") ||
                   istr.mediaType.match("application/rdf+xml")) {
            if (xmlParser == NULL)
                throw std::string("no XML parser to parse ")
                + istr.mediaType.toString()
                + " document " + nameStr;
            RdfXmlParser parser(nameStr, posFactory, xmlParser);
            if (baseURI != "")
                parser.setBase(baseURI);
            if (nsMap != NULL)
                parser.setNamespaceMap(nsMap);
            return parser.parse(target, istr);
        } else if (istr.mediaType.match("text/turtle") ||
                   istr.mediaType.match("text/ntriples")) {
            TurtleSDriver parser(nameStr, posFactory);
            parser.setGraph(target);
            if (baseURI != "")
                parser.setBase(baseURI);
            if (nsMap != NULL)
                parser.setNamespaceMap(nsMap);
            return parser.parse(istr);
        } else {
            TrigSDriver parser(nameStr, posFactory);
            parser.setDB(this);
            if (baseURI != "")
                parser.setBase(baseURI);
            if (nsMap != NULL)
                parser.setNamespaceMap(nsMap);
            return parser.parse(istr);
        }
    } catch (ChangeMediaTypeException& e) {
        rb.replay();
        io::stream_buffer<w3c_sw::StreamRewinder::Device> sb2(rb.device);
        std::istream is2(&sb2);
        IStreamContext again(istrP.nameStr, is, e.mediaType.c_str());
        return handler->parse(e.mediaType, e.args, target, again, nameStr, baseURI, posFactory, nsMap);
    }
}
Пример #11
0
int lazy_protocol::maybe_have_delim(tstring const& input)
{
    size_t pos =  input.find_first_of(waiter_delim_.data(), waiter_delim_.size());
    if( pos == tstring::npos ) {
        again();
        return 0;
    }
    return call(waiter_method_, tstring(input.data(), pos));
}
Пример #12
0
int lazy_protocol::maybe_have_enough_bytes(tstring const& input)
{
    if( input.size() < waiter_count_ ) {
        again();
        return 0;
    }
    
    return call(waiter_method_, tstring(input.data(), waiter_count_));
}
Пример #13
0
			virtual void ready() 
			{ 
				again();
				if (iOwner.iSpeedCounter != 0)
					iOwner.iSpeedSamples[(iOwner.iSpeedCounter++)%kSpeedSamples] = iOwner.iBytesTransferred - iOwner.iLastBytesTransferred;
				else
					for (std::size_t i = 0; i < kSpeedSamples; ++i)
						iOwner.iSpeedSamples[(iOwner.iSpeedCounter++)%kSpeedSamples] = iOwner.iBytesTransferred - iOwner.iLastBytesTransferred;
				iOwner.iLastBytesTransferred = iOwner.iBytesTransferred;
			}
	timer& timer::operator=(const timer& aOther)
	{
		if (waiting())
			cancel();
		iDuration_ms = aOther.iDuration_ms;
		iEnabled = aOther.iEnabled;
		if (aOther.waiting())
			again();
		return *this;
	}
		timer(const timer& aOther) :
			iOwnerThread(aOther.iOwnerThread),
			iTimerObject(aOther.iOwnerThread.io_service()),
			iDuration_ms(aOther.iDuration_ms), 
			iWaiting(false), 
			iCancelling(false)
		{
			if (aOther.waiting())
				again();
		}
		timer(io_thread& aOwnerThread, uint32_t aDuration_ms = 10, bool aInitialWait = true) : 
			iOwnerThread(aOwnerThread),
			iTimerObject(aOwnerThread.io_service()),
			iDuration_ms(aDuration_ms), 
			iWaiting(false), 
			iCancelling(false)
		{
			if (aInitialWait)
				again();
		}
Пример #17
0
void play()
{
    nodelay(stdscr,1);
    int last=clock(),t=0;
    draw();
    while (1)
    {

        if (level[PLROW][px]==tree)
        {
            die();
        }

        switch (getch())
        {
        case '4':
        case KEY_LEFT:
        case ',':
            last=clock();
            if (level[PLROW][px] == snow) level[PLROW][px]=ltrail;
            px--;
            adv();
            break;
        case'6':
        case KEY_RIGHT:
        case'.':
            last=clock();
            if (level[PLROW][px] == snow) level[PLROW][px]=rtrail;
            px++;
            adv();
            break;
        case'5':
        case' ':
        case KEY_DOWN:
            last=clock();
            if (level[PLROW][px] == snow) level[PLROW][px]=dtrail;
            adv();
            break;
        case'q':
        case'Q':
            again();
            break;
        default:
            break;
        }
        t=clock()-last;
        if (t>=magicNumber)
        {
            if (level[PLROW][px] == snow) level[PLROW][px]=dtrail;
            adv();
            last=clock();
        }
    }
}
	void timer::set_duration(uint32_t aDuration_ms, bool aEffectiveImmediately)
	{
		iDuration_ms = aDuration_ms;
		if (aEffectiveImmediately && waiting())
		{
			neolib::lifetime::destroyed_flag destroyed{ *this };
			cancel();
			if (destroyed)
				return;
			again();
		}
	}
	timer::timer(async_task& aIoTask, uint32_t aDuration_ms, bool aInitialWait) :
		iIoTask(aIoTask),
		iHandlerProxy(new handler_proxy(*this)),
		iTimerObject(aIoTask.timer_io_service().native_object()),
		iDuration_ms(aDuration_ms), 
		iEnabled(true),
		iWaiting(false), 
		iInReady(false)
	{
		if (aInitialWait)
			again();
	}
Пример #20
0
void display()
{
    int j;
    int i;
    printf("\t\t  <TIC-TAC-TOE>\n");
	for(j = 0; j < 10;j++)
	{
		printf("  ");
	}
	for(j = 0;j < 3;j++)
	{
		printf(" - ");
	}
	printf("\n");
	for(i = 0;i < 3;i++)
	{
		for(j = 0; j < 10;j++)
		{
			printf("  ");
		}
		for(j = 0;j < 3;j++)
		{
			printf("|%c|",ch[i][j]);
		}
		printf("\n");
		for(j = 0; j < 10;j++)
		{
			printf("  ");
		}
		for(j = 0;j < 3;j++)
		{
			printf(" - ");
		}
		printf("\n");
	}

	if(count)
	{
		if(player == 1)
		{
			play1();
		}
		else
		{
			play2();
		}
	}
	else
	{
		printf("\n----------------------------------->END OF GAME<-------------------------------\n");
		again();
	}
}
	timer::timer(const timer& aOther) :
		iIoTask(aOther.iIoTask),
		iHandlerProxy(new handler_proxy(*this)),
		iTimerObject(aOther.iIoTask.timer_io_service().native_object()),
		iDuration_ms(aOther.iDuration_ms), 
		iEnabled(aOther.iEnabled),
		iWaiting(false), 
		iInReady(false)
	{
		if (aOther.waiting())
			again();
	}
int main()
{

    struct timeval tv;
    do
    {
        gettimeofday(&tv, NULL); //get the time is usecs to use as the seed for srand.
        srand(tv.tv_usec); // for randomization

        play();
    } while(again()==1); //play the game again till the user wants to quit.

    return 0;
}
Пример #23
0
void out()
{
getch();
clrscr();
gotoxy(54,3);
cout<<"---[|-|@R|\/|Y";
gotoxy(13,2);
cout<<"STACK GAME";
gotoxy(13,11);
cout<<"SoRRy you out";
getch();
again();
getch();
}
Пример #24
0
/*
 * Clusters data.
 */
static void kmeans(void)
{	
	int i;

	omp_set_num_threads(NUM_THREADS);
	for (i = 0; i < NUM_THREADS; i++)
		omp_init_lock(&lock[i]);
	
	/* Cluster data. */
	do
	{	
		populate();
		compute_centroids();
	} while (again());
}
Пример #25
0
void again()
{
	char choose;
	printf("\nIf you want to play again press (Y) else press any other key to exit:");
	fflush(stdin);
	scanf("%c",&choose);
	fflush(stdin);
	if(choose == 'Y' || choose == 'y')
	{
		init();
		system("cls");
		display();
		again();

	}
}
Пример #26
0
void die()
{
    beep();
    nodelay(stdscr,0);
    mvaddch(PLROW,LEFTMOST+px,'@'|COLOR_PAIR(COLOR_RED)|A_BOLD);
    px=XSIZE/2;
    turn+=YSIZE;
    empty();
    life--;
    getch();
    if (life<1)
    {
        again();
    }
    nodelay(stdscr,1);
}
Пример #27
0
Файл: 2.c Проект: el-tillias/mdh
int main(void) {


    while (1) {

        int input[100];
        int z, c, strlength = 0;

        printf("Type an integer between 1 and 1000, max 100 integers in each run: ");

        while (scanf("%d", &c)) {

            if (c < 0 || strlength > 100) {
                break;
            }
            else if (c > 1000) {
                printf("Valid integers are between 1 and 1000\n");
            }

            else {
                input[strlength] = c;
                strlength++;
            }

            printf("Type another integer: ");
        }

        qsort(input, strlength, sizeof(int), cmpfunc);
        print_top(input, strlength);

        z = again();

        if (z == 1) {
            //memset(input, 0, sizeof(input));
            continue;

        }
        else if (z == 0) {
            break;
        }

    }

    return 0;
}
Пример #28
0
int runFib(int a){
    //Variable Declaration
    unsigned long long b,c,f;

    b = 0;
    c = 0;
    f = 0;

    //base case 1
    if(a < 0){
        printf("n cannot be less than zero.");
        getInput();
    }

    //base case 2
    if(a == 0){
        printf("Result: %d\n\n", 0);
        main();
    }

    //base case 3
    if(a == 1 | a == 2){
        printf("Result: %d\n\n", 1);
        main();
    }

    //the algorithm
    b = 1, c = 1;
    while(a > 2){
        f = b + c;
        b = c;
        c = f;
        a--;
    }

    //Result
    printf("Result: %lld\n\n", f);
    //loop
    again();
}
Пример #29
0
int main (int argc, char **argv) {
  int score, highscore= 0;
  int i;
  col_width = WIDTH;

  if (argc == 2) col_width = atoi(argv[1]);
  if (col_width > 20) col_width = WIDTH;
  if (col_width <= 0) col_width = WIDTH;

  init();
  do {
    score = play();
    if (score > highscore) highscore = score;
  } while (again (highscore));
  endwin();

  for (i = 0; i < col_width + 2; i++) {
      free(buf[i]);
  }
  free(buf);

  return 0;
}
Пример #30
0
// runs the current mission - called each tick. Don't call in non-mission mode.
// Returns 1 if the game continues, 0 if game over (although this is currently ignored and the game over status is set by this function)
static int run_mission(void)
{

// int i;

// special mission-specific code:
 switch(game.mission_index)
 {
 	case MISSION_TUTORIAL1:
 		switch(mission_state.phase)
 		{
			 case MPHASE1_START:
   	 clear_console(CONSOLE_SYSTEM);
//   	 play_interface_sound(SAMPLE_BLIP3, TONE_2C);
			 	write_mission_text(PRINT_COL_WHITE,
/*"Program initialised. Spawning process 0.\n\*/
"\nWelcome!\n\
To begin, select the blue base process near the centre of the display (by left-clicking on it).");

			 	write_mission_text(PRINT_COL_LBLUE,
"\n\n(For information about controls, or to quit, open the system panel at any time by clicking on the Sy button in the top right of the display).");

    	mission_state.phase = MPHASE1_SELECT;
    	break;
				case MPHASE1_SELECT:
					if (command.selected_core [0] == 0) // can assume builder is process 0
					{
    	 clear_console(CONSOLE_SYSTEM);
    	 play_interface_sound(SAMPLE_BLIP3, TONE_2C);
 			 	write_mission_text(PRINT_COL_WHITE,
"This process is a builder/harvester base.\
\nIt harvests raw data from the nearby data well and allocates it. Then it uses allocated data to \
build new processes.\
\n\nBut the data from a single well won't be enough! Build a mobile harvester by clicking on the \"harvester\" button on the left of the display.");

    	 mission_state.phase = MPHASE1_BUILD;
					}
					break;
				case MPHASE1_BUILD:
					if (w.core[1].exists > 0)
					{
    	 clear_console(CONSOLE_SYSTEM);
    	 play_interface_sound(SAMPLE_BLIP3, TONE_2C);
 			 	write_mission_text(PRINT_COL_WHITE,
"The harvester will take a few seconds to finish constructing.\
\nSelect it and tell it to move near a different data well. Data wells are shown in yellow on the map at the bottom right of the display.");
// \n\nSelect it and tell it to move near a different data well. Data wells are shown in yellow on the map at the bottom right of the display.");
			 	write_mission_text(PRINT_COL_LBLUE,
"\n\n(Give movement commands by right-clicking on the display or the map. You don't need to click exactly on the well, just nearby.)");
    	 mission_state.phase = MPHASE1_FIND_WELL;
					}
					break;
				case MPHASE1_FIND_WELL:
					if (distance_oct_xyxy(w.core[1].core_position.x, w.core[1].core_position.y,
																											w.data_well[1].position.x, w.data_well[1].position.y) < al_itofix(600)
						|| distance_oct_xyxy(w.core[1].core_position.x, w.core[1].core_position.y,
																											w.data_well[2].position.x, w.data_well[2].position.y) < al_itofix(600))
					{
    	 clear_console(CONSOLE_SYSTEM);
    	 play_interface_sound(SAMPLE_BLIP3, TONE_2C);
 			 	write_mission_text(PRINT_COL_WHITE,
"You can leave the harvester alone, and it will gather data to take back to the base.\
\n\nNow find the base again (you can click on the map to move the display around) and tell it to build an \"attacker\" process.");
    	 mission_state.phase = MPHASE1_BUILD_ATTACKERS;
					}