contract ContracoinSale is Crowdsale, AllowanceCrowdsale, WhitelistedCrowdsale {
  bool public isFinalized = false;

  constructor(
    uint _rate,
    address _wallet,
    MintableToken _token,
    address _tokenWallet
  )
    Crowdsale(_rate, _wallet, _token)
    AllowanceCrowdsale(_tokenWallet)
    public
  {
  }

  /**
  * @dev Allows admin to update the crowdsale rate
  * @param _rate Crowdsale rate
  */
  function setRate(uint _rate) public onlyOwner {
    rate = _rate;
  }

  /**
   * @dev Extend parent behavior requiring to be within contributing period
   * @param _beneficiary Token purchaser
   * @param _weiAmount Amount of wei contributed
   */
  function _preValidatePurchase(
    address _beneficiary,
    uint256 _weiAmount
  )
    internal
    onlyWhileOpen
  {
    super._preValidatePurchase(_beneficiary, _weiAmount);
  }

  /**
   * @dev Reverts if not in crowdsale time range.
   */
  modifier onlyWhileOpen {
    require(!isFinalized);
    _;
  }

  /**
  * @dev Allows admin to finalize the crowdsale
  */
  function finalize() public onlyOwner {
    require(!isFinalized);
    isFinalized = true;
  }

}
function setRate(uint _rate) public onlyOwner {
    rate = _rate;
  }
/**
 * @dev Allows admin to update the crowdsale rate
 * @param _rate Crowdsale rate
 */