Thread: [HELP] Deal Or No Deal game.

  1. #16
    Registered User
    Join Date
    Sep 2012
    Posts
    8
    The program you posted is fine, thank you sir - I'll try working on it to hide the values of the briefcases *if i can* ( they should only show up after I select a briefcase ) . everything else is pretty much working.

  2. #17
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by dnates2012 View Post
    The program you posted is fine, thank you sir - I'll try working on it to hide the values of the briefcases *if i can* ( they should only show up after I select a briefcase ) . everything else is pretty much working.
    The values of the unopened briefcases SHOULD show up, all the time. (This is the "board" that they can view to see what values are left). The NUMBERS of the (unopened) briefcase should also be shown, (so the player would know what cases can still be chosen) -- but the briefcase number should NOT be associated with the money value that briefcase holds.

    So the display needs to be altered to show both the money values left in the unopened briefcases, AND the number of the unopened briefcases, but with no connection between these two values (briefcase # to money #).

    Test it thoroughly, because I did not test it, and programs almost always have bugs in them, until they get some "bug spraying" done. You've seen this already.
    Last edited by Adak; 09-17-2012 at 09:18 AM.

  3. #18
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Little bug killer:

    Replace the old top few lines in main with this:
    Code:
    int main(){
       long int a[MAXCASE]={0,1,2,5,10,25,50,75,100,200,300,400,500,750,1000,5000,
          10000,25000,50000,75000,100000,200000,300000,400000,500000,750000,1000000};
       long int bankerOffer,sum,divideBy;
       int isOpen[27];
       int remainingCase,choice,mainBriefcase,toChoose;
       char chchoice;
    
       int i,j,deal,roundNum,temp,youWon;
    sum is now a long int, and there's a new variable "divideBy", that is also a long.

    There is a bug in the bankerOffer calculation. This is the fix for it:

    Code:
          printf("Now we'll see what the banker will offer. Here's the phone call now\a\a\a\n");
          sum=0;
          divideBy=0;
          for(i=1;i<MAXCASE;i++) {
             if(isOpen[i]==0) {
                sum+=a[i];
                divideBy++;
             }
          }
          bankerOffer = sum/divideBy;
    and in the amount that you win when you make a deal, replace these lines, to fix a bug there:

    Code:
          printf("Now the question to you is: Deal, or No Deal [y/n]: ");
          scanf(" %c",&chchoice);
          getchar();
          if(chchoice=='y' || chchoice=='Y') {
             deal=1;
             youWon=bankerOffer;
          }
       }
    
       printf("Thanks for playing Deal or No Deal ");
       if(deal==1) {
          printf("You won %ld", bankerOffer);
       }
       else {
          printf("You won : %ld", a[mainBriefcase]);
    Most of the above lines are correct, but included so you can find where the correct lines of code go, inside the program.

    Should be a simple copy and paste.

    I thought for the display of the dollar amounts still remaining WITHOUT having their briefcases numbered, it could be done like this:

    in showCases(), make a long int a2[MAXCASE], array. Then in a for loop from 1 to MAXCASE-1, copy the a[] array over to the a2 array.

    Then sort the a2 array, (not the a[] array!), and display the a2 array, without the briefcase numbers, in sorted order.

    Then below that, use a similar for loop to go through the isOpen[] array. Any isOpen[i] that == 0, should print that i number. That is a briefcase that still can be chosen, so print them out:

    1 2 4 5 6 8 ... etc.

    and it looks very much like the board on the game. Regrettably, no pretty girls holding the cases.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal arrays
    By shel5210 in forum C Programming
    Replies: 2
    Last Post: 03-31-2010, 01:40 AM
  2. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 06:53 PM
  3. Replies: 5
    Last Post: 09-18-2008, 02:57 PM
  4. "Deal or No Deal" Game
    By jaromdl in forum C++ Programming
    Replies: 13
    Last Post: 12-05-2006, 03:40 PM