Need help making a dart score board source code.

So I want to make a code that keeps track of peoples scores when we play darts that is fairly organized.
I don't want someone to write the complete source code for me, since that would be very long anyways. However, I could use some pointers on how to go about it and what would be the best way to do it. I want to do this to get better with using functions, structures, array's etc. I have started writing part of it but I think going to scratch it and figure out better ways to go about it instead of typing a million lines that are not necessary.
Sorry for the crappy algorithm but this is the just of what I want it to do.

Dart code Algorithm

I want it to:
Ask how many people are playing(will need an int size)
Validate input
If more than one person is playing then ask for users names(array or structure)
Validate the input for names can’t be longer than 12 characters(string array names)
Save each players name.
Ask for what is the starting score(maybe struct players.scores)
Validate between 1 and 999(cons int maxscore and gamescore)


If its valid display the the menu:
(
********darts*******
1.Player calculator
{
If the player calculator is chosen then ask which player is trying to use it
Validate that is a current player.
Show the players total (struct name.score)
Ask how much it wants to subtract
Validate whether they busted or not
If they bust then set them back to their original score before that
Tell them they busted and display their total again
else if there score is zero then say they won and ask to play again.
else if they didn't bust display there current standing
Display their new score and go back to the menu
}
2.View player scores
{
Display every ones scores and wait for user to exit.
}
3.Restart
{
Break out of the loop and ask for players etc. again
}
4.Quit
{
End the program
}
Display whose turn it is.
)

cout<< "thanks for using_____";









Use an associative array (eg. std::map<>) to associate name (string) with score (int).
http://en.cppreference.com/w/cpp/container/map

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <map>
#include <string>

using score_board_type = std::map< std::string, int > ;
typedef std::map< std::string, int > score_board_type ; // alternative syntax

int main()
{
    score_board_type score_board ;

    // insert a new entry / update existing score of a player
    std::string name = "Daffy Duck" ;
    int score = 38 ;
    score_board[name] = score ;

    // increment the score of a player
    int delta = 9 ;
    score_board[name] += delta ;

    // check if an entry for a player exists
    const auto iter = score_board.find(name) ;
    if( iter != score_board.end() )
    {
        std::cout << "found player '" << name << "' score: " << iter->second << '\n' ;
    }

    // remove the entry for a playert
    score_board.erase(name) ;

    score_board[ "Bugs Bunny" ] = 63 ;
    score_board[ "Speedy Gonzales" ] = 84 ;
    score_board[ "Wile E. Coyote" ] = 72 ;

    // display player scores
    for( const auto& pair : score_board ) std::cout << pair.first << " : " << pair.second << '\n' ;
}

http://coliru.stacked-crooked.com/a/8397389b5db13abc
Topic archived. No new replies allowed.