//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract BoardMemberContract { struct BoardMember { address memberAddress; // Address of the board member string name; // Name of the board member uint256 joiningDate; // Timestamp of when the member joined } BoardMember[] public boardMembers; mapping(address => bool) public isBoardMember; event BoardMemberAdded(address indexed memberAddress, string name, uint256 joiningDate); event BoardMemberRemoved(address indexed memberAddress); function addBoardMember(address _memberAddress, string _name) public { require(!isBoardMember[_memberAddress]); require(bytes(_name).length > 0); BoardMember memory newMember = BoardMember({ memberAddress: _memberAddress, name: _name, joiningDate: block.timestamp }); boardMembers.push(newMember); isBoardMember[_memberAddress] = true; BoardMemberAdded(_memberAddress, _name, block.timestamp); } function removeBoardMember(address _memberAddress) public { require(isBoardMember[_memberAddress]); for (uint i = 0; i < boardMembers.length; i++) { if (boardMembers[i].memberAddress == _memberAddress) { // Move the last board member to this position and then shorten the array boardMembers[i] = boardMembers[boardMembers.length - 1]; delete boardMembers[boardMembers.length - 1]; boardMembers.length--; break; } } isBoardMember[_memberAddress] = false; BoardMemberRemoved(_memberAddress); } function getBoardMemberCount() public view returns (uint) { return boardMembers.length; } function getBoardMember(uint index) public view returns (address memberAddress, string name, uint256 joiningDate) { require(index < boardMembers.length); BoardMember memory member = boardMembers[index]; return (member.memberAddress, member.name, member.joiningDate); } function isAddressBoardMember(address _memberAddress) public view returns (bool) { return isBoardMember[_memberAddress]; } }
0.4.18