Improving Code Interface

This is a discussion on Improving Code Interface within the C Programming forums, part of the General Programming Boards category; Hi, I was wondering if someone would be willing to help me improve my code's interface its for a wheel ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Improving Code Interface

    Hi,
    I was wondering if someone would be willing to help me improve my code's interface its for a wheel of fortune/hangman type game. I won't post the whole code right now, but I just was wondering if there was anyone out there who would be interested. Thanks.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    People will generally read posts and reply with comments here.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    19
    Maybe if we could see the code we could help you. Are you trying to make it work better or are you trying to make it look better?

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Yes, we are very critical.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    26
    Would it be okay if I posted the code? Because a while back I posted a whole code and I kind of got scolded for it....

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Well, you'll get told off for posting a whole load of code with no particular good question (or you have a question which clearly relates to 5 lines, and you post 500 lines just because you have 500 lines of code).

    If you ask for a "code review", then you would need to post the pieces of code that you want reviewed and anything relating to that (e.g. data structures, type declarations and such).

    It is quite a task to review hundreds of lines of code, tho'.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > It is quite a task to review hundreds of lines of code, tho'.
    And it doesn't really help IMHO.

    For example if someone did up your car totally, everything you could think of -- you'd probably notice it's better but not know in detail how. You'd be overwhelmed by the changes, having learnt nothing. And asked to do the same to another car, you'd have no idea.

    Rather, "this is what we'll do here, and how we'll do it".

  8. #8
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by helloamuro View Post
    Hi,
    I was wondering if someone would be willing to help me improve my code's interface its for a wheel of fortune/hangman type game. I won't post the whole code right now, but I just was wondering if there was anyone out there who would be interested. Thanks.
    That means you wanted to improve on GUI part (if there is any GUI), well, post a screen shot!

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Or the API ... Not really GUI. interface can mean many things.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    26
    Sorry, I should clarify myself more. By interface I meant how the program looks when it runs. Below I have posted two functions (whose meanings are obvious from their titles). I think that to center everything correctly field widths need to be used. Please forgive me if this is a simple question; I'm currently a beginning C student and I only know the simple basics.
    Code:
    void print_puzzle (int size, char puzzle[], char clue[])
    {
    	int i;
    	printf("===============================\n");
    	printf("Puzzle\n");
    	printf("%s\n", clue); /*prints clue*/
    	printf("===============================\n\n"); 
    	for (i = 0; i < size; ++i){
    		printf("%c",puzzle[i]); /*prints word hidden*/
    		}
    	printf("\n\n===============================\n\n");
    }
    
    void print_score(int players, int score[])
    {
    	int p;
    	printf("\n");
    	for (p = 0; p < players; ++p){
    		printf("Player %d ", p+1); /*prints player numbers*/
    		}
    	
    	printf("\n");
    	
    	for (p = 0; p < players; ++p){
    		printf("======== ");
    		}
    	
    	printf("\n");
     
    	for (p = 0; p < players; ++p){
    		printf(" %d ", abs(score[p])); /*prints each players score*/
    		}
    	
    	printf("\n\n");
    }

  11. #11
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,622
    Do you have any idea what it should look like?

    Just a warning that dolling up your command line programs may not be worth it. Look at your keyboard right now. That's all the keys you can type portably without needing wider streams or multibyte characters. If you start printing obscure characters to draw boxes or something, then your code becomes more non-portable. That's not a good thing if you're in uni.

  12. #12
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Please post a screen shot.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    26
    Here is a screenshot. Sorry about the eraser, there was some personal info down there. I need the program to somehow print in the middle of a 40 row by 80 column screen. Any help is appreciated. Others are displayed, but I don't feel comfortable posting them all unless someone is willing to help me via email. Thanks again.
    Here are the main functions displayed:
    Code:
    void print_puzzle (int size, char puzzle[], char clue[], int round)
    {
    	int i;
    	printf("                                      ===============================\n");
    	printf("                                                  Round %d\n", round+1);
    	printf("                                      ===============================\n\n"); 
    	printf("Clue: %s\n\n", clue); /*prints clue*/
    	for (i = 0; i < size; ++i){
    		printf("%2c",puzzle[i]); /*prints word hidden*/
    	}
    	printf("\n\n");
    
    }
    
    void print_score(int players, int score[])
    {
    	int p;
    	printf("\n");
    	for (p = 0; p < players; ++p){
    		printf("      Player %d ", p+1); /*prints player numbers*/
    		}
    	
    	printf("\n");
    	
    	for (p = 0; p < players; ++p){
    		printf("      ======== ");
    		}
    	
    	printf("\n");
     
    	for (p = 0; p < players; ++p){
    		printf("        $%d     ", abs(score[p])); /*prints each players score*/
    		}
    	
    	printf("\n\n");
    }
    
    
    
    
    int player_turn(int player_num, int player, int score[], char phrase[], char puzzle[], char clue[], int size, int round){
    	
    	int solved = 0; /*solve is initialized to zero to indicate puzzle has not been solved*/
    	char player_continues = 1;
    	char options[10]; /*string to hold choice*/
    
    	while (player_continues == 1){
    		char choice = ' '; /*choice initialized to nothing*/
    		print_score(player_num, score);
    		print_puzzle(size, puzzle, clue, round);
    		printf("Player %d, what do you want to do?\n\n", player+1);
    		while (choice != 'S' && choice != 'O' && choice != 'B') {
    			printf("(S)pin, S(o)lve or (B)uy a vowel -> ");
    			if(fgets(options,10,stdin))
    				{
    					sscanf(options, "%c", &choice); /*player types in choice and it is stored in options*/
    				}
    
    			choice = to_upper(choice); /*converts choice to uppercase to prevent case sensitivity*/
    			printf("\n");
    			}
    		if (choice == 'S'){ /*if player chooses spin*/
    			player_continues = spin(player, score, phrase, puzzle, size);
    			}
    		else if (choice == 'O'){ /*if player chooses solve*/
    			solved = solve(player, score, phrase, size, clue, round);
    			player_continues = 0;
    			}
    		else /* buy a vowel */{
    			player_continues = buy_vowel(player, score, phrase, puzzle, size);
    			}
    		}
    	return solved;
    }
    Attached Images Attached Images  

  14. #14
    Registered User
    Join Date
    Apr 2008
    Posts
    26
    I should also mention that I would like to know how to clear the screen once a player has chosen a letter and that letter is revealed. Thanks

  15. #15
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,449
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help improving code
    By jamort in forum C++ Programming
    Replies: 5
    Last Post: 05-28-2009, 05:13 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  4. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 08:04 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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