Yahtzee score selection

This is a discussion on Yahtzee score selection within the C Programming forums, part of the General Programming Boards category; Hey, I have to program the game yahtzee and at some point I have to check if the score selection ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    14

    Yahtzee score selection

    Hey,

    I have to program the game yahtzee and at some point I have to check if the score selection is correct. It's correct if the input matches the score types and if the score isn't used already.

    the code for select score:

    Code:
    static void select_score (int scores [], int dice [])
    {
    	int i, score;
    
    	do
    	{
    		printf("Choose a free category to score your roll:\n");
    
    		for (i = 0; i < NUM_OF_ROUNDS; i++)
    		{
    			printf ("%d\t%s", i + 1, selectable_score_names[i]);
    			printf (" %s\n", check_score (scores, i) == score_used ? "(used)" : "(unused)");
    		}
    
    		scanf ("%d", &score);
    		score--;
    	}
    	while (! is_valid_score_selection (scores, score));
    
    	add_score (score, scores, dice);
    }
    
    static int game_ended (int scores [])
    {
    	return 0;
    }
    And i have to make the is_valid_score_selection.
    Also I have to use:

    Code:
    enum score_type
    {
    	unused = -1,
    	aces,
    	twos,
    	threes,
    	fours,
    	fives,
    	sixes,
    	three_of_a_kind,
    	four_of_a_kind,
    	full_house,
    	small_straight,
    	large_straight,
    	yathzee,
    	chance,
    	bonus_upper_part,
    	total_upper_part,
    	total_lower_part,
    	total,
    	num_of_scores
    };
    I hope some one can help.
    Last edited by Kurdo; 12-12-2010 at 04:34 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    And where is the problem you're having? It looks to me like the instructor gave you an assignment with code snippets to use and you haven't put any work into it.

    We're not here to do your homework for you. Try to do it yourself and if you get stuck on a specific problem, ask us for help and we'll do the best we can to help you figure it out. However, asking us to just do the whole thing for you isn't appropriate.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting lowest and highest score from array
    By sjalesho in forum C Programming
    Replies: 6
    Last Post: 03-01-2011, 05:24 PM
  2. Can anyone help?
    By javalurnin in forum C Programming
    Replies: 11
    Last Post: 12-02-2009, 05:02 AM
  3. Doubt with scaning characters
    By georgio777 in forum C Programming
    Replies: 6
    Last Post: 11-16-2009, 11:38 PM
  4. C program using structs to calculate grades
    By TampaTrinDM88 in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 12:33 PM
  5. trouble with creating a loop to read certain number of inputs
    By import tuner650 in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2008, 07:28 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21