contract Crowdsale {
    using SafeMath for uint256;

    // The token being sold
    Token public token;

    // start timestamps
    uint256 public startTime = block.timestamp;

    // address where funds are collected
    address payable public wallet;

    // how many token units a buyer gets per wei
    uint256 public rate;

    // amount of raised money in wei
    uint256 public weiRaised;

    /**
     * event for token purchase logging
     * @param purchaser who paid for the tokens
     * @param beneficiary who got the tokens
     * @param value weis paid for purchase
     * @param amount amount of tokens purchased
     */
    event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

    constructor (address payable _wallet, Token _token) public{
        rate = 5;
        wallet = _wallet;
        token = _token;
    }

    // fallback function can be used to buy tokens
    fallback() external payable {
        buyTokens(msg.sender,msg.value);
    }

    // low level token purchase function
    function buyTokens(address beneficiary, uint256 weiAmount) internal {
        require(beneficiary != address(0));
        require(msg.value != 0);

        // calculate token amount to be created
        uint256 tokens = weiAmount.mul(getRate());

        // update state
        weiRaised = weiRaised.add(weiAmount);

        token.transfer(beneficiary, tokens);
        TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

        forwardFunds();
    }

    // send ether to the fund collection wallet
    // override to create custom fund forwarding mechanisms
    function forwardFunds() internal {
        wallet.transfer(msg.value);
    }


    // @return the crowdsale rate
    function getRate() public view returns (uint256) {
        return rate;
    }


}
function getRate() public view returns (uint256) {
    return rate;
}

// @return the crowdsale rate