Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.142.124.119
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/bafreeman/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/bafreeman/pirategold.cpp
// 	File name:      piratesgold2-Ben-F.cpp
//      Author:         Benjamin Freeman
//      Instructor:     Mrs. Ames
//      Due date:       Thurs., Sep. 4, 2008
//      Compilation:    g++ piratesgold2-Ben-F.cpp -o piratesgold2-Ben-F.out
//      Execution:      ./piratesgold2-Ben-F.out
//
//      Goal: This program will play the card game Pirate's Gold.      



#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include "cardclass.cpp"


void PlayPirateGame(DeckType deck);


int main()
{
   DeckType deck;

   srand(time(0));

   deck.Shuffle();

   PlayPirateGame(deck);

   return 0;
}


void PlayPirateGame (DeckType deck)
{
	typedef CardType HandType[DECKSIZE];

	HandType hand1, hand2;

	int tablecards, i,j,l,g,m,p;

	cout << "Pirate's Gold Game\n\n";
	cout << "Orignal Cards on Table:\n";
	cout << "------------------------\n";   
   	for (i=0; i < 8; i++)  
   	{ 
		hand1[i] = deck.DrawCard();
		hand1[i].Print();
    		if (i==3)
		   cout << "\n";
		else
		   cout << " ";
		hand2[i]=hand1[i];		
 	}
	for(l=1; l<23; l++)
	{        
		for (g=0; g<8; g++)
		{
			m=g;		
			for (p=g+1; p<8; p++)
			{
				if (hand2[m].EqualFace(hand2[p]))
				{
					hand2[m]=deck.DrawCard();
					hand2[p]=deck.DrawCard();
					m=p;	
					break;
				}
			}
		
		}

		cout << " \n------------------------" << endl;
                cout << "Round " << l << "\n\n";
		
		for(j=0; j<8; j++)
                {
                	hand2[j].Print();
                        if (j==3)
                                cout << endl;
                        else
                                cout << " ";
                }
	}
	cout << "\n----------------------\n";
	if (deck.IsEmpty())
        	cout << "\n\nYou've won\n";
	else
		cout << "\n\nYou've lost\n";
	cout << endl;
}











Stv3n404 - 2023