Documentation for 8a368240e2

This commit is contained in:
github-actions
2024-08-30 17:22:07 +00:00
parent a1eb9bd385
commit 27c0a2f2f9
5155 changed files with 53816 additions and 36252 deletions

View File

@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: games/memory_game.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -11,9 +11,9 @@
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../cookie.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
@@ -43,18 +43,23 @@ MathJax.Hub.Config({
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(1); });
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
initMenu('../../',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
@@ -73,7 +78,7 @@ $(function() {
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('dd/d92/memory__game_8cpp.html','../../'); initResizable(); });
$(function(){initNavTree('dd/d92/memory__game_8cpp.html','../../'); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
@@ -100,6 +105,7 @@ $(function(){initNavTree('dd/d92/memory__game_8cpp.html','../../'); initResizabl
<div class="header">
<div class="summary">
<a href="#namespaces">Namespaces</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">memory_game.cpp File Reference</div></div>
</div><!--header-->
@@ -120,6 +126,15 @@ Include dependency graph for memory_game.cpp:</div>
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/d18/memory__game_8cpp__incl.svg" width="603" height="111"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d9c/namespacegames.html">games</a></td></tr>
<tr class="memdesc:da/d9c/namespacegames"><td class="mdescLeft">&#160;</td><td class="mdescRight">(Mini)game implementations. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html">games::memory_game</a></td></tr>
<tr class="memdesc:d8/d41/namespacegames_1_1memory__game"><td class="mdescLeft">&#160;</td><td class="mdescRight">Functions for the <a href="https://en.wikipedia.org/wiki/Matching_game" target="_blank">Memory Game</a> implementation. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a5bdc30951221eae9c33413ff9eb574f6" id="r_a5bdc30951221eae9c33413ff9eb574f6"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
@@ -127,31 +142,31 @@ Functions</h2></td></tr>
<tr class="memdesc:a5bdc30951221eae9c33413ff9eb574f6"><td class="mdescLeft">&#160;</td><td class="mdescRight">for sleep() <br /></td></tr>
<tr class="separator:a5bdc30951221eae9c33413ff9eb574f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a33167bb9cce6d527b478b4f6ae8c3f59" id="r_a33167bb9cce6d527b478b4f6ae8c3f59"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a33167bb9cce6d527b478b4f6ae8c3f59"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#a33167bb9cce6d527b478b4f6ae8c3f59">games::memory_game::is_number</a> (const T &amp;input)</td></tr>
<tr class="memitem:a33167bb9cce6d527b478b4f6ae8c3f59"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#a33167bb9cce6d527b478b4f6ae8c3f59">games::memory_game::is_number</a> (const T &amp;input)</td></tr>
<tr class="memdesc:a33167bb9cce6d527b478b4f6ae8c3f59"><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function to verify if the given input is a number or not. This is very useful to prevent the program being stuck in a loop. <br /></td></tr>
<tr class="separator:a33167bb9cce6d527b478b4f6ae8c3f59"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad573c8ae66ab66156d03e5e81bbba214" id="r_ad573c8ae66ab66156d03e5e81bbba214"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ad573c8ae66ab66156d03e5e81bbba214"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#ad573c8ae66ab66156d03e5e81bbba214">games::memory_game::init</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table)</td></tr>
<tr class="memitem:ad573c8ae66ab66156d03e5e81bbba214"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#ad573c8ae66ab66156d03e5e81bbba214">games::memory_game::init</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table)</td></tr>
<tr class="memdesc:ad573c8ae66ab66156d03e5e81bbba214"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the table with the letters. <br /></td></tr>
<tr class="separator:ad573c8ae66ab66156d03e5e81bbba214"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac589ef65abb0a6b9a7116ee0f9fd5280" id="r_ac589ef65abb0a6b9a7116ee0f9fd5280"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ac589ef65abb0a6b9a7116ee0f9fd5280"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#ac589ef65abb0a6b9a7116ee0f9fd5280">games::memory_game::print_table</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table)</td></tr>
<tr class="memitem:ac589ef65abb0a6b9a7116ee0f9fd5280"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#ac589ef65abb0a6b9a7116ee0f9fd5280">games::memory_game::print_table</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table)</td></tr>
<tr class="memdesc:ac589ef65abb0a6b9a7116ee0f9fd5280"><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function to print the table. <br /></td></tr>
<tr class="separator:ac589ef65abb0a6b9a7116ee0f9fd5280"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adc62ebb75853446656e24932bdc6dd6b" id="r_adc62ebb75853446656e24932bdc6dd6b"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:adc62ebb75853446656e24932bdc6dd6b"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#adc62ebb75853446656e24932bdc6dd6b">games::memory_game::reset_data</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table, int *answer, int *old_answer, int *memory_count)</td></tr>
<tr class="memitem:adc62ebb75853446656e24932bdc6dd6b"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#adc62ebb75853446656e24932bdc6dd6b">games::memory_game::reset_data</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table, int *answer, int *old_answer, int *memory_count)</td></tr>
<tr class="memdesc:adc62ebb75853446656e24932bdc6dd6b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility function that resets the data if the user enters an invalid value. <br /></td></tr>
<tr class="separator:adc62ebb75853446656e24932bdc6dd6b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5714d97649c0edd57b4fb449799676a3" id="r_a5714d97649c0edd57b4fb449799676a3"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a5714d97649c0edd57b4fb449799676a3"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#a5714d97649c0edd57b4fb449799676a3">games::memory_game::ask_data</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table, int *answer, int *old_answer, int *memory_count)</td></tr>
<tr class="memitem:a5714d97649c0edd57b4fb449799676a3"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#a5714d97649c0edd57b4fb449799676a3">games::memory_game::ask_data</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table, int *answer, int *old_answer, int *memory_count)</td></tr>
<tr class="memdesc:a5714d97649c0edd57b4fb449799676a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function that asks the user for their input in the table they previously chose. <br /></td></tr>
<tr class="separator:a5714d97649c0edd57b4fb449799676a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a370760f2b328ad341bcb77d82fa17b01" id="r_a370760f2b328ad341bcb77d82fa17b01"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a370760f2b328ad341bcb77d82fa17b01"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#a370760f2b328ad341bcb77d82fa17b01">games::memory_game::match</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table_empty, const int &amp;answer, bool *first_time, int *old_answer, int *memory_count)</td></tr>
<tr class="memitem:a370760f2b328ad341bcb77d82fa17b01"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#a370760f2b328ad341bcb77d82fa17b01">games::memory_game::match</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;table, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table_empty, const int &amp;answer, bool *first_time, int *old_answer, int *memory_count)</td></tr>
<tr class="memdesc:a370760f2b328ad341bcb77d82fa17b01"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if the two values given by the user match. <br /></td></tr>
<tr class="separator:a370760f2b328ad341bcb77d82fa17b01"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ceeea62d8fa6c563e2c66359fd73413" id="r_a3ceeea62d8fa6c563e2c66359fd73413"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a3ceeea62d8fa6c563e2c66359fd73413"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="#a3ceeea62d8fa6c563e2c66359fd73413">games::memory_game::assign_results</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table_empty, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table, int *answer, bool *first_time, int *old_answer, int *memory_count)</td></tr>
<tr class="memitem:a3ceeea62d8fa6c563e2c66359fd73413"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d8/d41/namespacegames_1_1memory__game.html#a3ceeea62d8fa6c563e2c66359fd73413">games::memory_game::assign_results</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table_empty, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *table, int *answer, bool *first_time, int *old_answer, int *memory_count)</td></tr>
<tr class="memdesc:a3ceeea62d8fa6c563e2c66359fd73413"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to assign the results to the table. <br /></td></tr>
<tr class="separator:a3ceeea62d8fa6c563e2c66359fd73413"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4" id="r_ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
@@ -164,371 +179,6 @@ Functions</h2></td></tr>
<p>It provides <b>3 different sizes</b> available that the user can choose (4x2, 5x2, 7x2). 7x2 being the biggest table size and hardest mode. The bigger the size, <b>the more letters are available</b>.</p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Panquesito7" target="_blank">David Leal</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a5714d97649c0edd57b4fb449799676a3" name="a5714d97649c0edd57b4fb449799676a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5714d97649c0edd57b4fb449799676a3">&#9670;&#160;</a></span>ask_data()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">void games::memory_game::ask_data </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>table</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>old_answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>memory_count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Function that asks the user for their input in the table they previously chose. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the table. </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">table</td><td>The table that's used to get the user's input and data. </td></tr>
<tr><td class="paramname">answer</td><td>The user's answer. </td></tr>
<tr><td class="paramname">old_answer</td><td>The user's previous answer. </td></tr>
<tr><td class="paramname">memory_count</td><td>A counter to check if the user has already answered two values. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 162</span> {</div>
<div class="line"><span class="lineno"> 163</span> (*old_answer) = (*answer);</div>
<div class="line"><span class="lineno"> 164</span> <a class="code hl_function" href="#ac589ef65abb0a6b9a7116ee0f9fd5280">print_table</a>(table);</div>
<div class="line"><span class="lineno"> 165</span> </div>
<div class="line"><span class="lineno"> 166</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\n\nType your response here (number index):\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 167</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; (*answer);</div>
<div class="line"><span class="lineno"> 168</span> </div>
<div class="line"><span class="lineno"> 169</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="#a33167bb9cce6d527b478b4f6ae8c3f59">is_number</a>((*answer))) {</div>
<div class="line"><span class="lineno"> 170</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nYou must enter a valid number.\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 171</span> <a class="code hl_function" href="#adc62ebb75853446656e24932bdc6dd6b">reset_data</a>(table, answer, old_answer, memory_count);</div>
<div class="line"><span class="lineno"> 172</span> }</div>
<div class="line"><span class="lineno"> 173</span> </div>
<div class="line"><span class="lineno"> 174</span> <span class="comment">// Increase the memory count, which will be later on used for checking if</span></div>
<div class="line"><span class="lineno"> 175</span> <span class="comment">// the user has already answered two values.</span></div>
<div class="line"><span class="lineno"> 176</span> (*memory_count)++;</div>
<div class="line"><span class="lineno"> 177</span> </div>
<div class="line"><span class="lineno"> 178</span> <span class="keywordflow">if</span> (((*answer) &gt; table.size()) || ((*answer) &lt; 1)) {</div>
<div class="line"><span class="lineno"> 179</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nYou can&#39;t check a value that doesn&#39;t exist (or an &quot;</span></div>
<div class="line"><span class="lineno"> 180</span> <span class="stringliteral">&quot;invalid number).\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 181</span> <a class="code hl_function" href="#adc62ebb75853446656e24932bdc6dd6b">reset_data</a>(table, answer, old_answer, memory_count);</div>
<div class="line"><span class="lineno"> 182</span> }</div>
<div class="line"><span class="lineno"> 183</span> </div>
<div class="line"><span class="lineno"> 184</span> <span class="keywordflow">if</span> ((*old_answer) == (*answer)) {</div>
<div class="line"><span class="lineno"> 185</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nYou can&#39;t check the same value twice.\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 186</span> <a class="code hl_function" href="#adc62ebb75853446656e24932bdc6dd6b">reset_data</a>(table, answer, old_answer, memory_count);</div>
<div class="line"><span class="lineno"> 187</span> }</div>
<div class="line"><span class="lineno"> 188</span> </div>
<div class="line"><span class="lineno"> 189</span> <span class="comment">// If two matches are answered already, but the user checkes a non-answered</span></div>
<div class="line"><span class="lineno"> 190</span> <span class="comment">// and an answered value, the program will mark it as no match, however, we</span></div>
<div class="line"><span class="lineno"> 191</span> <span class="comment">// must not allow the user to check the same value twice.</span></div>
<div class="line"><span class="lineno"> 192</span> <span class="keywordflow">if</span> ((table[(*answer) - 1] != 0) &amp;&amp;</div>
<div class="line"><span class="lineno"> 193</span> ((table[(*old_answer)] == 0) || (table[(*old_answer)] != 0))) {</div>
<div class="line"><span class="lineno"> 194</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nYou can&#39;t check the same value twice.\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 195</span> <a class="code hl_function" href="#adc62ebb75853446656e24932bdc6dd6b">reset_data</a>(table, answer, old_answer, memory_count);</div>
<div class="line"><span class="lineno"> 196</span> }</div>
<div class="line"><span class="lineno"> 197</span>}</div>
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="amemory__game_8cpp_html_a33167bb9cce6d527b478b4f6ae8c3f59"><div class="ttname"><a href="#a33167bb9cce6d527b478b4f6ae8c3f59">games::memory_game::is_number</a></div><div class="ttdeci">bool is_number(const T &amp;input)</div><div class="ttdoc">Utility function to verify if the given input is a number or not. This is very useful to prevent the ...</div><div class="ttdef"><b>Definition</b> memory_game.cpp:62</div></div>
<div class="ttc" id="amemory__game_8cpp_html_ac589ef65abb0a6b9a7116ee0f9fd5280"><div class="ttname"><a href="#ac589ef65abb0a6b9a7116ee0f9fd5280">games::memory_game::print_table</a></div><div class="ttdeci">void print_table(const std::vector&lt; T &gt; &amp;table)</div><div class="ttdoc">Utility function to print the table.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:123</div></div>
<div class="ttc" id="amemory__game_8cpp_html_adc62ebb75853446656e24932bdc6dd6b"><div class="ttname"><a href="#adc62ebb75853446656e24932bdc6dd6b">games::memory_game::reset_data</a></div><div class="ttdeci">void reset_data(const std::vector&lt; T &gt; &amp;, int *, int *, int *)</div><div class="ttdoc">Utility function that resets the data if the user enters an invalid value.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:211</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_a5714d97649c0edd57b4fb449799676a3_cgraph.svg" width="368" height="255"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="a3ceeea62d8fa6c563e2c66359fd73413" name="a3ceeea62d8fa6c563e2c66359fd73413"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3ceeea62d8fa6c563e2c66359fd73413">&#9670;&#160;</a></span>assign_results()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">void games::memory_game::assign_results </td>
<td>(</td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *</td> <td class="paramname"><span class="paramname"><em>table_empty</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *</td> <td class="paramname"><span class="paramname"><em>table</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool *</td> <td class="paramname"><span class="paramname"><em>first_time</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>old_answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>memory_count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to assign the results to the table. </p>
<p>Also checkes if the user has answered all the values already, as well as verify if the user made a match or not. </p><dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the tables. </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">table_empty</td><td>The table with no values, slowly assigned from <code>table</code> depending on the user's input. </td></tr>
<tr><td class="paramname">table</td><td>The table with the original values. </td></tr>
<tr><td class="paramname">answer</td><td>The user's answer. </td></tr>
<tr><td class="paramname">first_time</td><td>A boolean to check if the user has already answered a value. </td></tr>
<tr><td class="paramname">old_answer</td><td>The user's previous answer. </td></tr>
<tr><td class="paramname">memory_count</td><td>A counter to check if the user has already answered two values. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 291</span> {</div>
<div class="line"><span class="lineno"> 292</span> <span class="comment">// Search through the entire table and if the answer matches the index, show</span></div>
<div class="line"><span class="lineno"> 293</span> <span class="comment">// the value. If it doesn&#39;t match, hide both the values. Don&#39;t forget to</span></div>
<div class="line"><span class="lineno"> 294</span> <span class="comment">// keep older values already answered.</span></div>
<div class="line"><span class="lineno"> 295</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; (*table).size() + 1; i++) {</div>
<div class="line"><span class="lineno"> 296</span> <span class="keywordflow">if</span> (i == (*answer)) {</div>
<div class="line"><span class="lineno"> 297</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="#a370760f2b328ad341bcb77d82fa17b01">match</a>((*table), table_empty, (*answer), first_time, old_answer,</div>
<div class="line"><span class="lineno"> 298</span> memory_count) == <span class="keyword">true</span>) {</div>
<div class="line"><span class="lineno"> 299</span> (*table_empty)[i - 1] = (*table)[i - 1];</div>
<div class="line"><span class="lineno"> 300</span> (*first_time) = <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 301</span> }</div>
<div class="line"><span class="lineno"> 302</span> }</div>
<div class="line"><span class="lineno"> 303</span> }</div>
<div class="line"><span class="lineno"> 304</span> </div>
<div class="line"><span class="lineno"> 305</span> <span class="keywordflow">if</span> ((*memory_count) == 1) {</div>
<div class="line"><span class="lineno"> 306</span> (*first_time) = <span class="keyword">false</span>;</div>
<div class="line"><span class="lineno"> 307</span> (*memory_count) = 0;</div>
<div class="line"><span class="lineno"> 308</span> }</div>
<div class="line"><span class="lineno"> 309</span> </div>
<div class="line"><span class="lineno"> 310</span> <span class="keywordtype">char</span> try_again = <span class="charliteral">&#39;n&#39;</span>;</div>
<div class="line"><span class="lineno"> 311</span> </div>
<div class="line"><span class="lineno"> 312</span> <span class="comment">// Has the user finished the game? Use a `for` loop, and if the table is</span></div>
<div class="line"><span class="lineno"> 313</span> <span class="comment">// full, ask the user if he wants to play again.</span></div>
<div class="line"><span class="lineno"> 314</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; (*table).size() + 1; i++) {</div>
<div class="line"><span class="lineno"> 315</span> <span class="keywordflow">if</span> ((*table_empty)[i] == 0) {</div>
<div class="line"><span class="lineno"> 316</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 317</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (i == (*table).size() - 1) {</div>
<div class="line"><span class="lineno"> 318</span> <a class="code hl_function" href="#ac589ef65abb0a6b9a7116ee0f9fd5280">print_table</a>((*table));</div>
<div class="line"><span class="lineno"> 319</span> </div>
<div class="line"><span class="lineno"> 320</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\n\nYou won. Congratulations! Do you want to play &quot;</span></div>
<div class="line"><span class="lineno"> 321</span> <span class="stringliteral">&quot;again? (y/n)\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 322</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div>
<div class="line"><span class="lineno"> 323</span> &lt;&lt; <span class="stringliteral">&quot;Size &quot;</span> &lt;&lt; (*table).size()</div>
<div class="line"><span class="lineno"> 324</span> &lt;&lt; <span class="stringliteral">&quot; will be used. This can be changed by re-running the game.&quot;</span>;</div>
<div class="line"><span class="lineno"> 325</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; try_again;</div>
<div class="line"><span class="lineno"> 326</span> <span class="keywordflow">if</span> (try_again == <span class="charliteral">&#39;y&#39;</span>) {</div>
<div class="line"><span class="lineno"> 327</span> <span class="comment">// This is needed when checking if the user has two matches</span></div>
<div class="line"><span class="lineno"> 328</span> <span class="comment">// already.</span></div>
<div class="line"><span class="lineno"> 329</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; (*table_empty).size(); i++) {</div>
<div class="line"><span class="lineno"> 330</span> (*table_empty)[i] = 0;</div>
<div class="line"><span class="lineno"> 331</span> }</div>
<div class="line"><span class="lineno"> 332</span> </div>
<div class="line"><span class="lineno"> 333</span> <a class="code hl_function" href="#ad573c8ae66ab66156d03e5e81bbba214">init</a>(table);</div>
<div class="line"><span class="lineno"> 334</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (try_again == <span class="charliteral">&#39;n&#39;</span>) {</div>
<div class="line"><span class="lineno"> 335</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nThanks for playing the game!\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 336</span> <a class="code hl_function" href="#a5bdc30951221eae9c33413ff9eb574f6">SLEEP</a>(3);</div>
<div class="line"><span class="lineno"> 337</span> </div>
<div class="line"><span class="lineno"> 338</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/program/exit.html">exit</a>(0);</div>
<div class="line"><span class="lineno"> 339</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 340</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nInvalid input (exitting...).\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 341</span> <a class="code hl_function" href="#a5bdc30951221eae9c33413ff9eb574f6">SLEEP</a>(3);</div>
<div class="line"><span class="lineno"> 342</span> </div>
<div class="line"><span class="lineno"> 343</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/program/exit.html">exit</a>(0);</div>
<div class="line"><span class="lineno"> 344</span> }</div>
<div class="line"><span class="lineno"> 345</span> }</div>
<div class="line"><span class="lineno"> 346</span> }</div>
<div class="line"><span class="lineno"> 347</span> </div>
<div class="line"><span class="lineno"> 348</span> <span class="comment">// Ask data again.</span></div>
<div class="line"><span class="lineno"> 349</span> <a class="code hl_function" href="#a5714d97649c0edd57b4fb449799676a3">ask_data</a>((*table_empty), answer, old_answer, memory_count);</div>
<div class="line"><span class="lineno"> 350</span> <a class="code hl_function" href="#a3ceeea62d8fa6c563e2c66359fd73413">assign_results</a>(table_empty, table, answer, first_time, old_answer,</div>
<div class="line"><span class="lineno"> 351</span> memory_count);</div>
<div class="line"><span class="lineno"> 352</span>}</div>
<div class="ttc" id="aexit_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/program/exit.html">std::exit</a></div><div class="ttdeci">T exit(T... args)</div></div>
<div class="ttc" id="amemory__game_8cpp_html_a370760f2b328ad341bcb77d82fa17b01"><div class="ttname"><a href="#a370760f2b328ad341bcb77d82fa17b01">games::memory_game::match</a></div><div class="ttdeci">bool match(const std::vector&lt; T &gt; &amp;table, std::vector&lt; T &gt; *table_empty, const int &amp;answer, bool *first_time, int *old_answer, int *memory_count)</div><div class="ttdoc">Checks if the two values given by the user match.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:235</div></div>
<div class="ttc" id="amemory__game_8cpp_html_a3ceeea62d8fa6c563e2c66359fd73413"><div class="ttname"><a href="#a3ceeea62d8fa6c563e2c66359fd73413">games::memory_game::assign_results</a></div><div class="ttdeci">void assign_results(std::vector&lt; T &gt; *table_empty, std::vector&lt; T &gt; *table, int *answer, bool *first_time, int *old_answer, int *memory_count)</div><div class="ttdoc">Function to assign the results to the table.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:289</div></div>
<div class="ttc" id="amemory__game_8cpp_html_a5714d97649c0edd57b4fb449799676a3"><div class="ttname"><a href="#a5714d97649c0edd57b4fb449799676a3">games::memory_game::ask_data</a></div><div class="ttdeci">void ask_data(const std::vector&lt; T &gt; &amp;table, int *answer, int *old_answer, int *memory_count)</div><div class="ttdoc">Function that asks the user for their input in the table they previously chose.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:161</div></div>
<div class="ttc" id="amemory__game_8cpp_html_a5bdc30951221eae9c33413ff9eb574f6"><div class="ttname"><a href="#a5bdc30951221eae9c33413ff9eb574f6">SLEEP</a></div><div class="ttdeci">constexpr T SLEEP(T seconds)</div><div class="ttdoc">for sleep()</div><div class="ttdef"><b>Definition</b> memory_game.cpp:36</div></div>
<div class="ttc" id="amemory__game_8cpp_html_ad573c8ae66ab66156d03e5e81bbba214"><div class="ttname"><a href="#ad573c8ae66ab66156d03e5e81bbba214">games::memory_game::init</a></div><div class="ttdeci">void init(std::vector&lt; T &gt; *table)</div><div class="ttdoc">Initializes the table with the letters.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:80</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_a3ceeea62d8fa6c563e2c66359fd73413_cgraph.svg" width="570" height="502"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="ad573c8ae66ab66156d03e5e81bbba214" name="ad573c8ae66ab66156d03e5e81bbba214"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad573c8ae66ab66156d03e5e81bbba214">&#9670;&#160;</a></span>init()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">void games::memory_game::init </td>
<td>(</td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *</td> <td class="paramname"><span class="paramname"><em>table</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes the table with the letters. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the table. </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">table</td><td>The table to initialize. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 80</span> {</div>
<div class="line"><span class="lineno"> 81</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;char&gt;</a> letters(7);</div>
<div class="line"><span class="lineno"> 82</span> </div>
<div class="line"><span class="lineno"> 83</span> <span class="comment">// Decrease / increase the number of letters depending on the size.</span></div>
<div class="line"><span class="lineno"> 84</span> <span class="keywordflow">if</span> ((*table).size() == 10) { <span class="comment">// 5x2</span></div>
<div class="line"><span class="lineno"> 85</span> letters = {<span class="charliteral">&#39;A&#39;</span>, <span class="charliteral">&#39;E&#39;</span>, <span class="charliteral">&#39;Z&#39;</span>, <span class="charliteral">&#39;P&#39;</span>, <span class="charliteral">&#39;D&#39;</span>};</div>
<div class="line"><span class="lineno"> 86</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((*table).size() == 8) { <span class="comment">// 4x2</span></div>
<div class="line"><span class="lineno"> 87</span> letters = {<span class="charliteral">&#39;A&#39;</span>, <span class="charliteral">&#39;E&#39;</span>, <span class="charliteral">&#39;Z&#39;</span>, <span class="charliteral">&#39;D&#39;</span>};</div>
<div class="line"><span class="lineno"> 88</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((*table).size() == 14) { <span class="comment">// 7x2</span></div>
<div class="line"><span class="lineno"> 89</span> letters = {<span class="charliteral">&#39;A&#39;</span>, <span class="charliteral">&#39;E&#39;</span>, <span class="charliteral">&#39;Z&#39;</span>, <span class="charliteral">&#39;P&#39;</span>, <span class="charliteral">&#39;D&#39;</span>, <span class="charliteral">&#39;B&#39;</span>, <span class="charliteral">&#39;M&#39;</span>};</div>
<div class="line"><span class="lineno"> 90</span> }</div>
<div class="line"><span class="lineno"> 91</span> </div>
<div class="line"><span class="lineno"> 92</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;char&gt;</a> pairs;</div>
<div class="line"><span class="lineno"> 93</span> <span class="keywordflow">for</span> (<span class="keywordtype">char</span> letter : letters) {</div>
<div class="line"><span class="lineno"> 94</span> pairs.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(letter);</div>
<div class="line"><span class="lineno"> 95</span> pairs.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(letter);</div>
<div class="line"><span class="lineno"> 96</span> }</div>
<div class="line"><span class="lineno"> 97</span> </div>
<div class="line"><span class="lineno"> 98</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/random_shuffle.html">std::shuffle</a>(pairs.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/begin.html">begin</a>(), pairs.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/end.html">end</a>(),</div>
<div class="line"><span class="lineno"> 99</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine.html">std::mt19937</a>(<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/random_device.html">std::random_device</a>()()));</div>
<div class="line"><span class="lineno"> 100</span> </div>
<div class="line"><span class="lineno"> 101</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; (*table).size(); i++) {</div>
<div class="line"><span class="lineno"> 102</span> (*table)[i] = pairs[i];</div>
<div class="line"><span class="lineno"> 103</span> }</div>
<div class="line"><span class="lineno"> 104</span> </div>
<div class="line"><span class="lineno"> 105</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;All available types are: &quot;</span>;</div>
<div class="line"><span class="lineno"> 106</span> </div>
<div class="line"><span class="lineno"> 107</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; letters.size(); i++) {</div>
<div class="line"><span class="lineno"> 108</span> <span class="keywordflow">if</span> (i == letters.size() - 1) {</div>
<div class="line"><span class="lineno"> 109</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;and &quot;</span> &lt;&lt; letters[i] &lt;&lt; <span class="stringliteral">&quot;.\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 110</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 111</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; letters[i] &lt;&lt; <span class="stringliteral">&quot;, &quot;</span>;</div>
<div class="line"><span class="lineno"> 112</span> }</div>
<div class="line"><span class="lineno"> 113</span> }</div>
<div class="line"><span class="lineno"> 114</span>}</div>
<div class="ttc" id="abegin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/begin.html">std::vector::begin</a></div><div class="ttdeci">T begin(T... args)</div></div>
<div class="ttc" id="aend_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/end.html">std::vector::end</a></div><div class="ttdeci">T end(T... args)</div></div>
<div class="ttc" id="amersenne_twister_engine_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine.html">std::mt19937</a></div></div>
<div class="ttc" id="apush_back_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">std::vector::push_back</a></div><div class="ttdeci">T push_back(T... args)</div></div>
<div class="ttc" id="arandom_device_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/random_device.html">std::random_device</a></div></div>
<div class="ttc" id="arandom_shuffle_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/random_shuffle.html">std::shuffle</a></div><div class="ttdeci">T shuffle(T... args)</div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_ad573c8ae66ab66156d03e5e81bbba214_cgraph.svg" width="368" height="234"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="a33167bb9cce6d527b478b4f6ae8c3f59" name="a33167bb9cce6d527b478b4f6ae8c3f59"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a33167bb9cce6d527b478b4f6ae8c3f59">&#9670;&#160;</a></span>is_number()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">bool games::memory_game::is_number </td>
<td>(</td>
<td class="paramtype">const T &amp;</td> <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Utility function to verify if the given input is a number or not. This is very useful to prevent the program being stuck in a loop. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the input </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">input</td><td>The input to check. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>false if the input IS empty or if it contains a non-digit character </dd>
<dd>
true if the input is NOT empty and if it contains only digit characters </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 62</span> {</div>
<div class="line"><span class="lineno"> 63</span> <span class="keywordflow">if</span> (<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a>.fail()) {</div>
<div class="line"><span class="lineno"> 64</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a>.clear();</div>
<div class="line"><span class="lineno"> 65</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a>.ignore(256, <span class="charliteral">&#39;\n&#39;</span>);</div>
<div class="line"><span class="lineno"> 66</span> </div>
<div class="line"><span class="lineno"> 67</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><span class="lineno"> 68</span> }</div>
<div class="line"><span class="lineno"> 69</span> </div>
<div class="line"><span class="lineno"> 70</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 71</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_a33167bb9cce6d527b478b4f6ae8c3f59_cgraph.svg" width="166" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&#160;</a></span>main()</h2>
@@ -538,7 +188,7 @@ Here is the call graph for this function:</div>
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"></span></td><td>)</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
@@ -577,7 +227,7 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 382</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nChoose table size: &quot;</span>;</div>
<div class="line"><span class="lineno"> 383</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; selection;</div>
<div class="line"><span class="lineno"> 384</span> } <span class="keywordflow">while</span> ((selection &lt; 1 || selection &gt; 3) &amp;&amp;</div>
<div class="line"><span class="lineno"> 385</span> (!games::memory_game::is_number(selection)));</div>
<div class="line"><span class="lineno"> 385</span> (!<a class="code hl_function" href="../../d8/d41/namespacegames_1_1memory__game.html#a33167bb9cce6d527b478b4f6ae8c3f59">games::memory_game::is_number</a>(selection)));</div>
<div class="line"><span class="lineno"> 386</span> </div>
<div class="line"><span class="lineno"> 387</span> <span class="keywordflow">switch</span> (selection) {</div>
<div class="line"><span class="lineno"> 388</span> <span class="keywordflow">case</span> 1:</div>
@@ -599,244 +249,27 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 404</span> </div>
<div class="line"><span class="lineno"> 405</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 406</span> </div>
<div class="line"><span class="lineno"> 407</span> <a class="code hl_function" href="#ad573c8ae66ab66156d03e5e81bbba214">games::memory_game::init</a>(&amp;table);</div>
<div class="line"><span class="lineno"> 408</span> <a class="code hl_function" href="#a5714d97649c0edd57b4fb449799676a3">games::memory_game::ask_data</a>(table_empty, &amp;response, &amp;old_answer,</div>
<div class="line"><span class="lineno"> 407</span> <a class="code hl_function" href="../../d8/d41/namespacegames_1_1memory__game.html#ad573c8ae66ab66156d03e5e81bbba214">games::memory_game::init</a>(&amp;table);</div>
<div class="line"><span class="lineno"> 408</span> <a class="code hl_function" href="../../d8/d41/namespacegames_1_1memory__game.html#a5714d97649c0edd57b4fb449799676a3">games::memory_game::ask_data</a>(table_empty, &amp;response, &amp;old_answer,</div>
<div class="line"><span class="lineno"> 409</span> &amp;memory_count);</div>
<div class="line"><span class="lineno"> 410</span> <a class="code hl_function" href="#a3ceeea62d8fa6c563e2c66359fd73413">games::memory_game::assign_results</a>(&amp;table_empty, &amp;table, &amp;response,</div>
<div class="line"><span class="lineno"> 410</span> <a class="code hl_function" href="../../d8/d41/namespacegames_1_1memory__game.html#a3ceeea62d8fa6c563e2c66359fd73413">games::memory_game::assign_results</a>(&amp;table_empty, &amp;table, &amp;response,</div>
<div class="line"><span class="lineno"> 411</span> &amp;first_time, &amp;old_answer, &amp;memory_count);</div>
<div class="line"><span class="lineno"> 412</span> </div>
<div class="line"><span class="lineno"> 413</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 414</span>}</div>
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="anamespacegames_1_1memory__game_html_a33167bb9cce6d527b478b4f6ae8c3f59"><div class="ttname"><a href="../../d8/d41/namespacegames_1_1memory__game.html#a33167bb9cce6d527b478b4f6ae8c3f59">games::memory_game::is_number</a></div><div class="ttdeci">bool is_number(const T &amp;input)</div><div class="ttdoc">Utility function to verify if the given input is a number or not. This is very useful to prevent the ...</div><div class="ttdef"><b>Definition</b> memory_game.cpp:62</div></div>
<div class="ttc" id="anamespacegames_1_1memory__game_html_a3ceeea62d8fa6c563e2c66359fd73413"><div class="ttname"><a href="../../d8/d41/namespacegames_1_1memory__game.html#a3ceeea62d8fa6c563e2c66359fd73413">games::memory_game::assign_results</a></div><div class="ttdeci">void assign_results(std::vector&lt; T &gt; *table_empty, std::vector&lt; T &gt; *table, int *answer, bool *first_time, int *old_answer, int *memory_count)</div><div class="ttdoc">Function to assign the results to the table.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:289</div></div>
<div class="ttc" id="anamespacegames_1_1memory__game_html_a5714d97649c0edd57b4fb449799676a3"><div class="ttname"><a href="../../d8/d41/namespacegames_1_1memory__game.html#a5714d97649c0edd57b4fb449799676a3">games::memory_game::ask_data</a></div><div class="ttdeci">void ask_data(const std::vector&lt; T &gt; &amp;table, int *answer, int *old_answer, int *memory_count)</div><div class="ttdoc">Function that asks the user for their input in the table they previously chose.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:161</div></div>
<div class="ttc" id="anamespacegames_1_1memory__game_html_ad573c8ae66ab66156d03e5e81bbba214"><div class="ttname"><a href="../../d8/d41/namespacegames_1_1memory__game.html#ad573c8ae66ab66156d03e5e81bbba214">games::memory_game::init</a></div><div class="ttdeci">void init(std::vector&lt; T &gt; *table)</div><div class="ttdoc">Initializes the table with the letters.</div><div class="ttdef"><b>Definition</b> memory_game.cpp:80</div></div>
<div class="ttc" id="asrand_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/srand.html">std::srand</a></div><div class="ttdeci">T srand(T... args)</div></div>
<div class="ttc" id="atime_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/c/time.html">std::time</a></div><div class="ttdeci">T time(T... args)</div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="188" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="a370760f2b328ad341bcb77d82fa17b01" name="a370760f2b328ad341bcb77d82fa17b01"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a370760f2b328ad341bcb77d82fa17b01">&#9670;&#160;</a></span>match()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">bool games::memory_game::match </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>table</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; *</td> <td class="paramname"><span class="paramname"><em>table_empty</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const int &amp;</td> <td class="paramname"><span class="paramname"><em>answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool *</td> <td class="paramname"><span class="paramname"><em>first_time</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>old_answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>memory_count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Checks if the two values given by the user match. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the table. </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">table_empty</td><td>The table with no values, slowly assigned from <code>table</code> depending on the user's input. </td></tr>
<tr><td class="paramname">table</td><td>The table with the original values. </td></tr>
<tr><td class="paramname">answer</td><td>The user's answer. </td></tr>
<tr><td class="paramname">first_time</td><td>A boolean to check if the user has already answered a value. </td></tr>
<tr><td class="paramname">old_answer</td><td>The user's previous answer. </td></tr>
<tr><td class="paramname">memory_count</td><td>A counter to check if the user has already answered two values. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true IF the values given by the user match </dd>
<dd>
false if the values given by the user do NOT match </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 237</span> {</div>
<div class="line"><span class="lineno"> 238</span> <span class="keywordflow">if</span> ((*first_time) == <span class="keyword">true</span>) {</div>
<div class="line"><span class="lineno"> 239</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 240</span> }</div>
<div class="line"><span class="lineno"> 241</span> </div>
<div class="line"><span class="lineno"> 242</span> <span class="comment">// Search across the whole table and if the two values match, keep results,</span></div>
<div class="line"><span class="lineno"> 243</span> <span class="comment">// otherwise, hide &#39;em up.</span></div>
<div class="line"><span class="lineno"> 244</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; table.size() + 1; i++) {</div>
<div class="line"><span class="lineno"> 245</span> <span class="keywordflow">if</span> (i == answer) {</div>
<div class="line"><span class="lineno"> 246</span> <span class="keywordflow">if</span> (table[i - 1] == table[(*old_answer) - 1]) {</div>
<div class="line"><span class="lineno"> 247</span> (*first_time) = <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 248</span> (*memory_count) = 0;</div>
<div class="line"><span class="lineno"> 249</span> </div>
<div class="line"><span class="lineno"> 250</span> (*old_answer) = 0;</div>
<div class="line"><span class="lineno"> 251</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 252</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 253</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nNo match (value was &quot;</span> &lt;&lt; table[i - 1]</div>
<div class="line"><span class="lineno"> 254</span> &lt;&lt; <span class="stringliteral">&quot;, index is &quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot;).\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 255</span> </div>
<div class="line"><span class="lineno"> 256</span> (*table_empty)[(*old_answer) - 1] = 0;</div>
<div class="line"><span class="lineno"> 257</span> (*table_empty)[answer - 1] = 0;</div>
<div class="line"><span class="lineno"> 258</span> </div>
<div class="line"><span class="lineno"> 259</span> (*first_time) = <span class="keyword">true</span>;</div>
<div class="line"><span class="lineno"> 260</span> (*memory_count) = 0;</div>
<div class="line"><span class="lineno"> 261</span> </div>
<div class="line"><span class="lineno"> 262</span> (*old_answer) = 0;</div>
<div class="line"><span class="lineno"> 263</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><span class="lineno"> 264</span> }</div>
<div class="line"><span class="lineno"> 265</span> }</div>
<div class="line"><span class="lineno"> 266</span> }</div>
<div class="line"><span class="lineno"> 267</span> </div>
<div class="line"><span class="lineno"> 268</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><span class="lineno"> 269</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_a370760f2b328ad341bcb77d82fa17b01_cgraph.svg" width="166" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="ac589ef65abb0a6b9a7116ee0f9fd5280" name="ac589ef65abb0a6b9a7116ee0f9fd5280"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac589ef65abb0a6b9a7116ee0f9fd5280">&#9670;&#160;</a></span>print_table()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">void games::memory_game::print_table </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>table</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Utility function to print the table. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the table. </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">table</td><td>The table to print. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 123</span> {</div>
<div class="line"><span class="lineno"> 124</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;| &quot;</span>;</div>
<div class="line"><span class="lineno"> 125</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;T&gt;</a> table_print(table.size());</div>
<div class="line"><span class="lineno"> 126</span> </div>
<div class="line"><span class="lineno"> 127</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; table.size(); i++) {</div>
<div class="line"><span class="lineno"> 128</span> table_print[i] = <span class="charliteral">&#39; &#39;</span>;</div>
<div class="line"><span class="lineno"> 129</span> </div>
<div class="line"><span class="lineno"> 130</span> <span class="keywordflow">if</span> (table[i] != 0) {</div>
<div class="line"><span class="lineno"> 131</span> table_print[i] = table[i];</div>
<div class="line"><span class="lineno"> 132</span> }</div>
<div class="line"><span class="lineno"> 133</span> }</div>
<div class="line"><span class="lineno"> 134</span> </div>
<div class="line"><span class="lineno"> 135</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; table.size(); i++) {</div>
<div class="line"><span class="lineno"> 136</span> <span class="keywordflow">if</span> (i % 5 == 0 &amp;&amp; i != 0) {</div>
<div class="line"><span class="lineno"> 137</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\n| &quot;</span>;</div>
<div class="line"><span class="lineno"> 138</span> }</div>
<div class="line"><span class="lineno"> 139</span> </div>
<div class="line"><span class="lineno"> 140</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; table_print[i] &lt;&lt; <span class="stringliteral">&quot; | &quot;</span>;</div>
<div class="line"><span class="lineno"> 141</span> }</div>
<div class="line"><span class="lineno"> 142</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_ac589ef65abb0a6b9a7116ee0f9fd5280_cgraph.svg" width="166" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="adc62ebb75853446656e24932bdc6dd6b" name="adc62ebb75853446656e24932bdc6dd6b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adc62ebb75853446656e24932bdc6dd6b">&#9670;&#160;</a></span>reset_data()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="memname">
<tr>
<td class="memname">void games::memory_game::reset_data </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; T &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>table</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>old_answer</em>, </span></td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int *</td> <td class="paramname"><span class="paramname"><em>memory_count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Utility function that resets the data if the user enters an invalid value. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>The type of the table. </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">table</td><td>The table that will be used to call <code>ask_data()</code>. </td></tr>
<tr><td class="paramname">answer</td><td>The user's answer. </td></tr>
<tr><td class="paramname">old_answer</td><td>The user's previous answer. </td></tr>
<tr><td class="paramname">memory_count</td><td>A counter to check if the user has already answered two values. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 212</span> {</div>
<div class="line"><span class="lineno"> 213</span> (*answer) = (*old_answer);</div>
<div class="line"><span class="lineno"> 214</span> (*memory_count)--;</div>
<div class="line"><span class="lineno"> 215</span> </div>
<div class="line"><span class="lineno"> 216</span> <a class="code hl_function" href="#a5714d97649c0edd57b4fb449799676a3">ask_data</a>(table, answer, old_answer, memory_count);</div>
<div class="line"><span class="lineno"> 217</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_adc62ebb75853446656e24932bdc6dd6b_cgraph.svg" width="570" height="166"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dd/d92/memory__game_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="667" height="438"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
@@ -853,7 +286,7 @@ template&lt;typename T &gt; </div>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">constexpr T SLEEP </td>
<td class="memname">T SLEEP </td>
<td>(</td>
<td class="paramtype">T</td> <td class="paramname"><span class="paramname"><em>seconds</em></span></td><td>)</td>
<td></td>
@@ -880,7 +313,7 @@ template&lt;typename T &gt; </div>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_4b6f782e158b0b98da980a0e11a23a15.html">games</a></li><li class="navelem"><a class="el" href="../../dd/d92/memory__game_8cpp.html">memory_game.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0 </li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
</ul>
</div>
</body>