contract CrowdsaleToken is
StandardToken,
Configuration {
    /**
     * @dev enum of current crowd sale state
     **/
    enum Stages {none, start, end}

    Stages public currentStage;
    event BasePriceChanged(
        uint256 oldPrice,
        uint256 indexed newPrice
    );

    /**
     * @dev constructor of CrowdsaleToken
     **/
    constructor() public {
        currentStage = Stages.none;
    }

    /**
     * @dev fallback function to send ether to for Crowd sale
     **/
    function() external payable {
        require(
            currentStage == Stages.start,
            "ICO is not in start stage"
        );
        require(
            msg.value > 0,
            "transaction value is 0"
        );

        uint256 weiAmount = msg.value; // Calculate tokens to sell
        uint256 tokens = weiAmount.mul(basePrice);

        tokens_sold = tokens_sold.add(tokens); // Increment raised amount

        balances[msg.sender] = balances[msg.sender].add(tokens);
        emit Transfer(
            address(0x0),
            msg.sender,
            tokens
        );
        totalSupply_ = totalSupply_.add(tokens);
        address(
            uint160(owner)
        ).transfer(weiAmount); // Send money to owner
    }

    /**
     * @dev startICO starts the public ICO
     **/
    function startICO() public onlyOwner {
        require(
            currentStage == Stages.none,
            "ICO cannot only be started"
        );
        currentStage = Stages.start;
    }

    /**
     * @dev endIco closes down the ICO
     **/
    function endICO() internal {
        require(
            currentStage == Stages.start,
            "cannot end ICO"
        );
        currentStage = Stages.end;

        if (address(this).balance > 0) {
            address(
                uint160(owner)
            ).transfer(
                address(this).balance
            ); // Send money to owner
        }
    }

    /**
     * @dev finalizeIco closes down the ICO and sets needed varriables
     **/
    function finalizeICO() public onlyOwner {
        endICO();
    }

    /**
     * @dev change base price of token per ether
     **/
    function changeBasePrice(uint256 newBasePrice) public onlyOwner {
        require(
            newBasePrice > 0,
            "base price cannot be zero"
        );
        uint256 oldBasePrice = basePrice;
        basePrice = newBasePrice;

        emit BasePriceChanged(
            oldBasePrice,
            basePrice
        );
    }
}
/**
 * @title CrowdsaleToken
 * @dev Contract to preform crowd sale with token
 **/
function changeBasePrice(uint256 newBasePrice) public onlyOwner {
    require(
        newBasePrice > 0,
        "base price cannot be zero"
    );
    uint256 oldBasePrice = basePrice;
    basePrice = newBasePrice;

    emit BasePriceChanged(
        oldBasePrice,
        basePrice
    );
}

/**
 * @dev change base price of token per ether
 **/