contract BitplusCrowdsale is Crowdsale  {
  using SafeMath for uint256;
  event CrowdsaleMintFinished();

  uint256 public cap;

  function BitplusCrowdsale(uint256 _cap, uint256 _startBlock, uint256 _endBlock, uint256 _usdRate, uint256 _tokenPriceInCents, address _wallet) Crowdsale(_startBlock, _endBlock, _usdRate, _tokenPriceInCents, _wallet) {
    cap = _cap;
  }

  // overriding Crowdsale#validPurchase to add extra cap logic
  // @return true if investors can buy at the moment
  function validPurchase() internal constant returns (bool) {
    bool withinCap = weiRaised.add(msg.value) <= cap;
    return super.validPurchase() && withinCap;
  }

  // overriding Crowdsale#hasEnded to add cap logic
  // @return true if crowdsale event has ended
  function hasEnded() public constant returns (bool) {
    bool capReached = weiRaised >= cap;
    return super.hasEnded() || capReached;
  }
  
  // this function allows distribution by the owner before the 
  // actual public sale starts
  function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
      return token.mint(_to, _amount);
  }
  
  function changeTokenOwner(address _to) public onlyOwner {
      token.transferOwnership(_to);
  }

  // send ether to the fund collection wallet
  // override to create custom fund forwarding mechanisms
  function forwardFunds() public onlyOwner {
    wallet.transfer(this.balance);
  }  
  
  /**
   * @dev Function to stop minting new tokens in crowdsale(initial distribution).
   * @return True if the operation was successful.
   */
  function finishMinting() onlyOwner returns (bool) {
    return token.finishMinting();
  }  
  
}
function finishMinting() onlyOwner returns (bool) {
  return token.finishMinting();
}  

/**
 * @dev Function to stop minting new tokens in crowdsale(initial distribution).
 * @return True if the operation was successful.
 */