Example #1
0
void task3() {
  CircularList<int> clist;  
  cout << clist << endl;
  clist.insert(0,8);
  cout << clist << endl;
  clist.insert(1,5);
  cout << clist << endl;
  clist.insert(2,4);
  cout << clist << endl;
  clist.insert(0,0);
  cout << clist << endl;
  clist.insert(3,7);
  cout << clist << endl;
  clist.insert(5,9);
  cout << clist << endl;

  try { clist.insert(10,99); } catch (const char * e) { cout << e << endl; }

  cout << endl;
  
  CircularList<int> clist2(clist); 

  cout << clist.remove(5) << ": " << clist <<  endl;
  cout << clist.remove(1) << ": " << clist << endl;
  cout << clist.remove(0) << ": " << clist << endl;;

  cout << endl;

  cout << clist2 << endl;
  clist = clist2;
  clist2.clear();
  if(clist2.isEmpty()) cout << "Clear works correctly" << endl;
  cout << clist2 << endl;
  cout << clist << endl;
  cout << endl;

  CircularList<int> * cPtr = clist.clone();
  cout << *cPtr << endl;
  cout << cPtr->get(3) << " " << cPtr->get(0) << " " << cPtr->get(5) << endl;
  cout << *cPtr << endl;
  delete cPtr;
}
int main()
{
	srand((unsigned)time(NULL));
	string playerName;
	int nrOfCardDecks = 1;
	int cardSum = 0;
	int cardPos = 0;
	Card lastCard;

	Card cardDeck[SIZE];

	makeCardDeck(cardDeck);
	shuffleCardDeck(cardDeck);
	
	CircularList<Player> players;

	addPlayers(players);
	cout<<endl;
	cardPos = dealCards(cardDeck, players);
	
	while (players.size() > 1)
	{
		cout<<"Ny runda"<<endl;

		cardSum = 0;
		while (handleCurrentPlayer(cardDeck, cardPos, players, cardSum));
		
		cout<<players.currentItem().getName()<<" förlorade dennna runda"<<endl;
		players.remove(players.currentItem());
		// ny giv
		shuffleCardDeck(cardDeck);
		cardPos = dealCards(cardDeck, players);
	}

	cout<<"Segrare :"<<players.currentItem().getName()<<endl;

	return 0;	
}