Thread: Working on poker - commerce

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    141

    Working on poker - commerce

    can someone give me an idea please?


    please... really need help..

    http://cboard.cprogramming.com/attac...tid=6539&stc=1

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    You're going to need to show that you can do a bit more work on your own first before anybody's going to give you any help.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Something you should do before asking for help is write a program that will analyse a number of commerce hands stored in a text file and determine which of the hands is the winning hand based on the definition given on that PDF.

    If you do that, it should develop your skills in basic programming and problem solving.

    Then post your question...
    Sent from my iPadŽ

  4. #4
    Registered User
    Join Date
    Jan 2006
    Posts
    141
    ops sorry, ok here is the code

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    
    int main () 
    {
        string commerce;
        ifstream myfile ("input2.txt");
        
        if (myfile.is_open())
        {
            while (! myfile.eof() )
            {
                getline (myfile,commerce);
                cout << commerce << endl;
            }
        myfile.close();
        }
        
        else cout << "Unable to open file"; 
        
        system("pause");
        return 0;
    }

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Ok... that's about the first 10 percent of the assignment. Look ok so far. Just don't use system("pause") you should use cin.get() if you need to pause the program. And don't control your loop with eof(). You're better off controlling the loop with the actual input statement.
    Sent from my iPadŽ

  6. #6
    Registered User
    Join Date
    Jan 2006
    Posts
    141
    any other tips .. i really get stuck..

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    You want a tip or a solution? Just give it your best shot... then when you run into a specific problem, we're glad to help.
    Sent from my iPadŽ

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Code:
    while ( getline (myfile,commerce) ) {
      int score = getScoreForHand( commerce );
      cout << "hand " << commerce << " scored " << score << endl;
    }
    Code:
    int getScoreForHand( string &commerce ) {
      return 0;
    }
    First off is say print the names of the 3 cards - separate into tokens
    Then add something which assigns a value to each card
    Then add something which scores the hand according to the rules
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Jan 2006
    Posts
    141
    this is my code tat i have work for long time

    Code:
    /*******************************************************************************
    Commerce games(commerce.cpp)  
                                                     
    This program will analyse a number of a commerce hands stored in a text        
    file and determine which of the given hands is the winning hand.               
    ********************************************************************************/
    
    #include <iostream>
    #include <cstdlib>
    #include <fstream>
    #include <string>
    using namespace std;
    
    int main()
    {
    //declare numRows, numColumns and string
    
        const int numRows = 6;
        const int numColumns = 3;
        string hands[numRows][numColumns]; 
    
    //initialise the string and assign each to 'X'
          
        for(int row = 0; row < numRows; row++)
        {
            for(int col = 0; col <numColumns; col++)
            {
                hands[row][col] = "X";
            }
        }    
         
    //input from input.txt and display
    
        ifstream myfile ("input.txt");
        if(!myfile)
        {
            cout<<"Cannot open file."<<endl;
            return 1;
        }
            
        for(int row = 0; row < numRows; row++)
        {
            for(int col = 0; col <numColumns; col++)
            {
                myfile>>hands[row][col];
                cout<< hands[row][col] << " ";
            }
            cout<<endl;
        }
        myfile.close(); 
    
    //find the triplet
        
        for(int row = 0; row < numRows; row++)
        {
            for(int col = 0; col <numColumns; col++)
            {
                hands[row][col] = "A";
            }
        } 
                
        system("PAUSE");
        return 0;
    }
    can some one give me some useful hints...please

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM