contract CappedCrowdsale is Crowdsale {
    using SafeMath for uint256;

    uint256 private _hardcap;
    uint256 private _softcap;

    /**
     * @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
     * @param hardcap Max amount of wei to be contributed
     */
    constructor (uint256 hardcap, uint256 softcap) public {
        require(hardcap > 0, "CappedCrowdsale: hardcap is 0");
        require(softcap > 0, "CappedCrowdsale: softcap is 0");
        _hardcap = hardcap;
        _softcap = softcap;
    }

    /**
     * @return the hardcap of the crowdsale.
     */
    function hardcap() public view returns (uint256) {
        return _hardcap;
    }
    
     /**
     * @return the softcap of the crowdsale.
     */
    function softcap() public view returns (uint256) {
        return _softcap;
    }

    /**
     * @dev Checks whether the cap has been reached.
     * @return Whether the cap was reached
     */
    function hardcapReached() public view returns (bool) {
        return weiRaised() >= _hardcap;
    }
    
    /**
     * @dev Checks whether the softcap has been reached.
     * @return Whether the softcap was reached
     */
    function softcapReached() public view returns (bool) {
        return weiRaised() >= _softcap;
    }
     
     /**
     * @dev Extend parent behavior requiring purchase to respect the funding cap.
     * @param beneficiary Token purchaser
     * @param weiAmount Amount of wei contributed
     */
    function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
        super._preValidatePurchase(beneficiary, weiAmount);
        require(weiRaised().add(weiAmount) <= _hardcap, "CappedCrowdsale: cap exceeded");
    }
}
/**
 * @title CappedCrowdsale
 * @dev Crowdsale with a limit for total contributions.
 */
function softcapReached() public view returns (bool) {
    return weiRaised() >= _softcap;
}

/**
 * @dev Checks whether the softcap has been reached.
 * @return Whether the softcap was reached
 */