Beispiel #1
0
int main()
{

	Clock clock;

	clock.setDay(2);
	clock.setHour(23);
	clock.setMinute(59);
	clock.setSecond(55);

	cout << "Day: " << clock.getDay() << endl;
	cout << "Hour: " << clock.getHour() << endl;
	cout << "Minute: " << clock.getMinute() << endl;
	cout << "Second: " << clock.getSecond() << endl;

	cout << endl;

	system("Pause");

	bool done = false;

	while (!done)
	{
		system("cls");

		clock.tick();

		clock.output();

		Sleep(1000);
	}

	system("Pause");

	return 0;
}
Beispiel #2
0
void mainloop()
{
    //input the number of case
    int case_num;
    int case_count = 1;;
    cin >> case_num;
    for (; case_num > 0; case_num--)
    {
        Clock clock;
        Gameover = 1;
        cout << "Case " << case_count++ << ":" << endl;
        cin >> M >> N >> R >> K >> T;
        Headquarter* pMyHeadquarter[2];
        pMyHeadquarter[0] = new Headquarter(0,M);
        pMyHeadquarter[1] = new Headquarter(1,M);
        City* pCity[30];
        for (int i = 0; i<=N+1; i++)
        {
            pCity[i] = new City(i,&clock,pMyHeadquarter);
        }
        for( int i = 0; i < WARR_NUM; i++ )
            cin >> LifeElem[i];
        for( int i = 0; i < WARR_NUM; i++ )
            cin >> WarrAtk[i];
        //create two objects
        GameControl MainControl(pCity,pMyHeadquarter,&clock);
        while (clock.getTotalMinute()<= T)
        {
            if (Gameover == 0)
                break;
            switch (clock.getMinute())
            {
            case 0:
                pMyHeadquarter[0]->Produce(clock,pCity);
                pMyHeadquarter[1]->Produce(clock,pCity);
                clock.TimeGo(5);
                break;
            case 5:
                MainControl.AllLionEscape();
                clock.TimeGo(5);
                break;
            case 10:
                MainControl.Allmarch();
                MainControl.PrintMarch();
                clock.TimeGo(10);
                break;
            case 20:
                CityProduce(pCity,10);
                clock.TimeGo(10);
                break;
            case 30:
                MainControl.AllCollect();
                clock.TimeGo(5);
                break;
            case 35:
                MainControl.AllShot();
                clock.TimeGo(3);
                break;
            case 38:
                MainControl.AllBoom();
                clock.TimeGo(2);
                break;
            case 40:
                MainControl.Allattack();
                MainControl.AllAward();
                clock.TimeGo(10);
                break;
            case 50:
                pMyHeadquarter[0]->ReportElem(clock);
                pMyHeadquarter[1]->ReportElem(clock);
                clock.TimeGo(5);
                break;
            case 55:
                MainControl.AllReportWeapon();
                clock.TimeGo(5);
                break;
            }
        }
        delete [] pCity;
        delete [] pMyHeadquarter;
    }
}