2 Replies - 1766 Views - Last Post: 05 December 2012 - 07:19 AM Rate Topic: -----

#1 dodgebert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-December 12

Creating a program to simulate mancalla

Posted 04 December 2012 - 11:07 PM

Okay, I have been working on this for countless hours... I am told that all of these functions are wrong and I am needing to make the function "board" output what is in "int main". The following:
  solidLine();                //Produces the top solid line of the game board.
    endl(cout);
    
    numbers1();                 //*****************************************************************
    changingNum1(beadArray);             //Produces the top row of numbered tiles as well as bead count per
    solidLine();                // tile. Produces the top section of the game board as well.
    endl(cout);                 //*****************************************************************
    
    numbers2();                 //*****************************************************************
    changingNum2(beadArray);             //Produces the bottom row of numbered tiles as well as bead count
    solidLine();                //per tile. Produces the bottom section of the game board as well.
    endl(cout);                 //*****************************************************************



That is what board is supposed to output. I can't figure out how to make board do that at all. I don't have the strongest understanding of parameters and arguments and can't seem to find a good enough explanation for myself on google. Here is the entire program I have written so far.

#include <iostream>
#include <iomanip>
using namespace std;
const int MAX=14;
void line ();               //Creates dotted line
void spaces ();             // Creates spaces
void board ();              // Creates board
void solidLine();           // Creates Solid Line
void numbers1();            // Creates top row of numbers
void numbers2();            // Creates bottom row of numbers
void startArray(int beadArray[MAX], int bins);         //Begining array of all elements equaling '4'
void printArray(int beadArray[MAX]);          //Function to print the array
int changingNum1(int beadArray[MAX]);        //Function to display the top (0-6) tiles bead count
int changingNum2(int beadArray[MAX]);        //Function to display the bottom (7-13) tiles bead count
int gameOver(int beadArray[MAX]);
int player(int chooseBin);
int chooseBin(int player, int beadArray[MAX], int playerNumber);


int main ()
{
    int beadArray[MAX];          //Array giving each set it's beads, which is currently 0 and 4
    int winnerPlayer;            // Returns the winner's number 1 & 2.
    int bins=4;
    int highBin;
    int lowBin;
    
    
    startArray(beadArray, bins);
    solidLine();                //Produces the top solid line of the game board.
    endl(cout);
    
    numbers1();                 //*****************************************************************
    changingNum1(beadArray);             //Produces the top row of numbered tiles as well as bead count per
    solidLine();                // tile. Produces the top section of the game board as well.
    endl(cout);                 //*****************************************************************
    
    numbers2();                 //*****************************************************************
    changingNum2(beadArray);             //Produces the bottom row of numbered tiles as well as bead count
    solidLine();                //per tile. Produces the bottom section of the game board as well.
    endl(cout);                 //*****************************************************************
    for(int i=8; i<MAX; i++)
    {
        beadArray[i]=0;
        
    }
    winnerPlayer=gameOver(beadArray);
   
    
}


/*********************************
 Creates a dotted line 9 stars long
 with 6 spaces inbetween
 paramaters: none
 return value: none
 ********************************/
void line ()                //Counts spaces inbetween stars

{
    int count;
    for(int group = 0; group<8; group++)
    {
        count = 0;
        cout<<"*";
        while (count<6)
        {
            cout<< ' ';
            count++;
            
        }
        
    }
    cout<<'*'<<endl;
}

void solidLine()                        // Creates a solid line of stars
{
    int count;
    
    for(count=0; count< 57; count++)
    {
        cout<<'*';
        
    }
}


void board ()                          // Creates the game board
{
    int tally=0;
    solidLine();
    while (tally<2)
    {
        int count;
        for(count=0;count<5;count++)
        {
            line();
        }
        tally++;
        solidLine();
        endl(cout);
        
    }
}

void numbers1()                         // creates first level of numbers from 0-6
{
    int count;
    line();
    cout<<"*      *";
    //Goes from 0-6
    for (count = 0; count<6; count++)
    {
        cout<<setw(4)<<count<<setw(3)<<"*";
    }
    cout<<"   6  *"<<endl;
    for(count=0; count<2; count++)
    {
        line();
    }
    
}

void numbers2()                         // Creates second level of numbers from 7-13
{
    int count;
    line();
    cout<<"*  13  *";
    //Goes from 0-6
    for (count = 12; count>6; count--)
    {
        cout<<setw(4)<<count<<setw(3)<<"*";
    }
    cout<<"      *"<<endl;
    for(count=0; count<3; count++)
    {
        line();
    }
    
}


void printArray(int beadArray[MAX])                           //Function to print the array
{
    for (int i=0; i<=13; i++)                   //Loop to print the beadArray
    {
        
        cout<<' '<<beadArray[i];
    }
    
}

int changingNum1(int beadArray[MAX])                         // creates first level of changing numbers from 0-6
{
    int count;
    
    cout<<"*      *";
    //Goes from 0-6
    for (count = 0; count<7; count++)
    {
        cout<<setw(3)<<beadArray[count]<<setw(4)<<"*";
        
    }
    
    for(count=0; count<1; count++)
    {
        endl( cout);
        line();
    }
    
    
}

int changingNum2(int beadArray[MAX])                         // creates second level of changing numbers from 7-13
{
    
    int count;
    
    
    //Goes from 7-13
    for (count = 13; count>6; count--)
    {
        cout<<"*"<<setw(3)<<beadArray[count]<<setw(4);
        
    }
    cout<<"   *      *";
    for(count=0; count<1; count++)
    {
        endl( cout);
        line();
    }
    
    
}



void startArray(int beadArray[MAX], int bins)
{
    for (int i=0; i<MAX; i++)
    {
        beadArray[i]=bins;
    }
    beadArray[6]=0;
    beadArray[13]=0;
}

int gameOver(int beadArray[MAX])
{
    int leftOver=0;
    int endGame;
    
    for (int i=0; beadArray[i]==0 && i<7; i++)
    {
        endGame=1;
    }
    
    for (int i=8; beadArray[i]==0 && i<MAX; i++)
    {
        endGame=2;
    }
    cout<<endGame;
    
    
    
    if (endGame==1)
    {
        for(int i=8; i<MAX; i++)
        {
            
            beadArray[i]=++leftOver;
        }
    }
    
    
    if (endGame==2)
    {
        for(int i=0; i<6; i++)
        {
            beadArray[i]=++leftOver;
        }
    }
    
    
    cout<<"the leftover is "<<leftOver;
    return endGame;
}

int chooseBin(int playerNumber, int player, int beadArray[MAX])
{
    int bin=0;
    
    
    if ( playerNumber==1)
    {
        cout<<"What bin number do you choose?";
        cin>>bin;
    }
    if (bin>0&& bin<<6)
    {
        cin>>bin;
        
    }
    else
    {
        cout<<"Number must be inbetween 1 and 5.";
    }
    
    
    if (playerNumber ==2)
    {
        cout<<"What bin number do you choose?";
        cin>>bin;
    }
    if (bin>7 &&bin<<13)
    {
        cin>>bin;
    }
    else
    {
        cout<<"Number must be inbetween 7 and 12.";
    }
}

int player(int changingNum1, int changingNum2)
{
    int playerNumber=0;
    int turnOver=0;
    
    
    if (changingNum1 ==0 && changingNum2==0)
    {
        if (turnOver==1 && playerNumber==1)
        {
            playerNumber=2;
            turnOver=0;
        }
        else if(playerNumber==2 && turnOver==1)
        {
            playerNumber=1;
            turnOver=0;
        }
    }
}





Is This A Good Question/Topic? 0
  • +

Replies To: Creating a program to simulate mancalla

#2 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 183
  • View blog
  • Posts: 615
  • Joined: 11-June 11

Re: Creating a program to simulate mancalla

Posted 05 December 2012 - 06:40 AM

Quote

I don't have the strongest understanding of parameters and arguments and can't seem to find a good enough explanation for myself on google.


Functions
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5642
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: Creating a program to simulate mancalla

Posted 05 December 2012 - 07:19 AM

Perhaps I'm missing something. Don't you just need:
void printBoard(int beadArray[MAX]) {
	solidLine();                //Produces the top solid line of the game board.
	endl(cout);

	numbers1();                 //*****************************************************************
	changingNum1(beadArray);             //Produces the top row of numbered tiles as well as bead count per
	solidLine();                // tile. Produces the top section of the game board as well.
	endl(cout);                 //*****************************************************************

	numbers2();                 //*****************************************************************
	changingNum2(beadArray);             //Produces the bottom row of numbered tiles as well as bead count
	solidLine();                //per tile. Produces the bottom section of the game board as well.
	endl(cout);                 //*****************************************************************
}

// ...
// in main
    startArray(beadArray, bins);
    printBoard(beadArray);
    
    for(int i=8; i<MAX; i++) /* why 8? */
    {
        beadArray[i]=0;
        
    }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1