Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:27:04+00:00 2026-06-13T17:27:04+00:00

Problem: Creating a video poker game for my internet programming class. I have everything

  • 0

Problem: Creating a video poker game for my internet programming class.

I have everything else working except I’m missing something in my logic down below.
It returns true for Full House when all I have is 3 of a Kind.

I know my logic for the 3 of the kind works. But when comparing the two cards not involved in the 3 of a Kind is where something is wrong.

Here’s the code:

//Calculate if Full House exist
function checkHouse()
{
    $kindFlag = false;
    $pairFlag = false;
    $tempCardValue = 0;
    $temp = array();
    $counter = 0;

    //check for 3 of a kind, save card positions so they aren't tested for a pair
    for($i=0; $i<3; $i++)
    {
        for($j=($i+1); $j<4; $j++)
        {
            for($k=($j+1); $k<5; $k++)
            {
                if($this->Hand[$i]->GetSortValue() == $this->Hand[$j]->GetSortValue() && $this->Hand[$i]->GetSortValue() == $this->Hand[$k]->GetSortValue())
                {
                    $kindFlag =  true;
                    $tempCardValue = $this->Hand[$i]->GetSortValue();
                    break 3;
                }
            }
        }
    }

    //Checks 2 remaining cards to see if they match
    for($i=0; $i<5; $i++)
    {
        if($this->Hand[$i]->GetSortValue() != $tempCardValue)
        {
            $temp[$counter] = $this->Hand[$i]->GetSortValue();
            $counter++;
        }
    }
    if($temp[0] == $temp[1])
    {
        $pairFlag = true;
    }

    //Computes Full House or not
    if($pairFlag && $kindFlag)
        return true;
    else
        return false;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:27:05+00:00Added an answer on June 13, 2026 at 5:27 pm

    Just a suggestion, but you’re implementation of the cards seems overly complicated. It should be easy to do a check for pairs and fullhouses, and what not.

    start with a class called Card (this is from memory so there may be syntax errors and what not):

    class Card {
      var $index;
      var $suit; // 0 to 3 you can define which is what
      var $value; // 0 to 12, aces are 12 or 0 or you can actually put their value this is just quick and dirty
      function Card($index) {
          $this->index = index;
          $this->suit = index % 13;
          $this->value = index % 4;
      }
    }
    

    and then you can add a class called Hand and it would tabulate the result

    class Hand {
    
        $values = array(); // value of cards
        $suits = array();
        $cards = array();
    
        function Hand($cards) {
            $this->cards = $cards;
        }
        function checkResult() {
             foreach ($this->cards as $card) {
                  $values[$card->value]++;
                  $suits[$card->suit]++;
             }
    
        }
       function getPairs() {
           $pairs = array();
           foreach ($values as $key=>$value) {
               if ($value == 2) 
                   $pairs[] = $value;
    
           }
          return $pairs;
       }
    
       function getThreeOfAKind() {
          $result = false;
          foreach ($values as $key=>$value) {
             if ($value == 3)
               return $key;
           }
          return false;
       }
    
    }
    

    then you can call

    $hand = new Hand($arrayOfCards);
    $hand->checkResult();
    echo "This hand has this many pairs: " + count($hand->getPairs());
    echo "Full house? " + (count($hand->getPairs()) + $hand->getThreeOfAKind !== false);
    

    It’d be easy to implement the rest of the card checks in the Hand class:

    function checkFlush() {
       foreach ($this->suits as $suit=>$num) {
        if ($num == 5) 
          return $suit;
    
       }
      return false;
    }
    

    etc… I didn’t mean to write so much code, sorry, lol

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having problem in creating a video player in flash via as3, the
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have a problem creating a std::map<int, int> from a vector of pointers, called
I have a problem creating the following SQL Statement using LINQ & C# select
I have a problem creating and executing a JAR file. I have already made
I'm creating a video site like Youtube. The problem is that I can't understand
I have kind of a unique problem in the project I'm working in. What
I have a problem with creating Thumbnail from mp4 file which is in assets
I'm creating Video using FFMPEG from pngs. The problem is on creating the video,
I have been creating a custom video player for the web. On some machines

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.