-
-
Save hydai/1fc00629951108a31993a03b48f41158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.7.1; | |
contract StudentScores { | |
mapping(string => uint) scores; | |
string[] names; | |
function addScore(string memory name, uint score) public { | |
scores[name] = score; | |
names.push(name); | |
} | |
function getScore(string memory name) public view returns (uint) { | |
return scores[name]; | |
} | |
function clear() public { | |
while (names.length > 0) { | |
delete scores[names[names.length-1]]; | |
names.pop(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment