HW10: Top-up gym membership

Problem statement

Implement a smart contract for top-up gym membership management.

Example scenario

Alice owns a gym. She creates an instance of this contract to manage memberships, setting the daily price to 0.1 ether. Bob uploads 1 ether to his account. Every time Bob visits the gym, he shows his public address QR code to the receptionist who scans it and checks Bob's membership through the smart contract. When Bob enters, his balance is charged with the daily price. If Bob's last payment was at most 12 hours ago (e.g. he goes out during his training session to have a phone call), he does not have to pay again to enter.

Contract interface

Contract skeleton

pragma solidity ^0.4.21;

contract GymMembership {

    // <contract_variables>

    // </contract_variables>

    function GymMembership(uint256 dailyPrice) public {
        // TODO
    }

    function topUp() public payable {
        // TODO
    }

    function validate(address client) public {
        // TODO
    }

    function withdraw() public {
        // TODO
    }

}