For a class assignment we need to make a C++ program in putty of the game war. It has to have 7 functions; it's suppose to use a time() function and srand() function in the dealRandomCard() function. The output should be asking you how many cards you want to play; then displaying your card; give you the option to throw away 1 card; display the new cards; sort your cards and the computer's cards in accending order; then put your #1 card against the computers #1 card who's ever higher gets a point until all cards are played; then the computer tallies the points and informs the user if they won or lost.
Here's the thing I am completely lost and have little clue what I am doing. I was hoping someone could help point me in the right direction. The code that I have so far lists the 7 functions I have to use but some of them are commented out because I'm trying to build up to them. I'm also not sure about the time or rand code, what I have is something that we were shown in class but I don't think it's right.
Thank you, SSR.
My code so far:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
//void dealCardSet
void dealRandomCard (int[], int[], int);
//void showAllCards
int getOneNewCard (int);
//void dealRandCard
void bubblesort (int[], int[], int);
//void playwar
int main ()
{
int N, throwaway, cards[N], suit[N];
cout<<" How many cards do you want to play? -> ";
cin>>N;
dealRandomCard (cards, suit, N);
getOneNewCard (throwaway);
bubblesort (cards, suit, N);
return 0;
}
dealRandomCard (int card[N]; int suit[N]; N)
for(int a=0; a<N; a++)
{
card[a]=rand()%13+2;
suit[a]=rand()%4;
cout<<"Card"<<a <<" : " <<card[a]<<" ("<<suit[a]<<")"<<endl;
}
int getOneNewCard(int throwaway)
cout<<"If you want a new card, choose index of card to throw away.
Otherwise, type -1."<<endl;
cout<<"Your Choice = ";
cin>> throwaway;
while (throwaway!=-1)
{
}
void bubblesort (int cards[N], int suit[N], int N)
{
int a, b, temp, temp2;
for (a=0; a<N; a++)
for (b=0; (b<N-1); b++)
if (cards[b]<cards[b+1])
{
temp=cards[b];
cards[b]=cards[b+1];
cards[b+1] = temp;
temp2= suit[b];
suit[b]= suit[b+1];
suit[b+1]=temp2;
}
}