コード例 #1
0
//this function sets up the battle
void Battle::setupBattle(){
	Screen newScreen(0,0);
	newScreen.startScreen();
	for(int j=0; j<200; j++){
		Deque *newDeque = new Deque();//create the deque

		//create the heros
		Hare swordHare(true);
		Hare regHare(false);
		Tortoise swordTort(true);
		Tortoise regTort(false);

		//store pirates in the deque
		for(int i=0; i<10; i++){
			Pirate *newPirate = new Pirate();
			if(i%2 == 0){
				newDeque->pushFront(newPirate);
			}
			else{
				newDeque->pushBack(newPirate);
			}
		}
	
		//Deque *newDeque2;//this copies the deque into another one using the copy constructor from the deque class
		if(j%2 ==0)
			simulate(newDeque, &swordHare, &regTort);
		else
			simulate(newDeque, &regHare, &swordTort);

		delete newDeque;
	}
		results(newScreen);//output the results
}
コード例 #2
0
ファイル: Deque.cpp プロジェクト: parthnaik/cs106b
int main() {
    Deque d;
    
    d.pushFront(3);
    d.pushFront(5);
    d.pushBack(8);
    d.popBack();
    d.popFront();
    
    d.printDeque();
    
    return 0;
}