Load, process, and save changes to player statistics for a Spider Solitaire game
ID: 3834548 • Letter: L
Question
Load, process, and save changes to player statistics for a Spider Solitaire game using JSON format.
You will need to implement a JSON parser in C++ to read JSON from a file. Please see PlayerStatistics.json for an example of the expected format. Simulate a player winning 5 out of 5 One Suit games, 2 out of 5 Two Suits games, and 0 out of 5 Four Suits games. Don't forget to handle updating the statistics for Fastest Win and Fewest Moves. When done, your program should save the updated information to the PlayerStatistics.json file.
Provide the full code to this question. The libraries used must be included and written, and provide a screenshot that it compiles so I know for sure it compiles. No incomplete code.
PlayerStatistics.json file:
[
{
"Player Name": "Me",
"Overview": {
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
},
"Suits":
[
{
"Type": "One Suit",
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
},
{
"Type": "Two Suits",
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
},
{
"Type": "Four Suits",
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
}
]
},
{
"Player Name": "You",
"Overview":
{
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
},
"Suits":
[
{
"Type": "One Suit",
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
},
{
"Type": "Two Suits",
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
},
{
"Type": "Four Suits",
"Games Won": 0,
"Win Rate": 0,
"Games Played": 0,
"Fastest Win": 0,
"Fewest Moves": 0,
"Top Score": 0
}
]
}]