HW13: Smart parking

Problem statement

Implement a smart contract for smart parking.

Example scenario

Alice owns a parking lot. She creates an instance of this contract for each parking spot, setting the price per time slot to 0.01 ether.

Bob reserves one of the parking spots for the time slot between 10:00am and 11:00am this Sunday using his license plate number "ABC123". When the time arrives, Bob parks his car at the spot and leaves to do his business. The cameras in the parking lot detect his license plate number ("ABC123") and check if he has access to the parking spot at that time. If not, they might send a payment notice to the address associated with the plate number.

Contract interface

Contract skeleton

pragma solidity ^0.4.21;

contract SmartParking {

    // <contract_variables>

    // </contract_variables>

    function SmartParking(uint256 pricePerSlot) public {
        // TODO
    }

    function reserve(uint24 slotId, string licensePlate) public payable {
        // TODO
    }

    function transfer(uint24 slotId, address to, string newLicensePlate) public {
        // TODO
    }

    function validate(string licensePlate) public view returns (bool) {
        // TODO
    }

    function withdraw() public {
        // TODO
    }

}