Find the density of the sum $Z = X+Y$ when $X$ and $Y$ are independent, standard uniform random variables.
$$f_X(x) = 1\quad\mathrm{if}\quad 0\le x \le 1$$ $$f_Y(y) = 1\quad\mathrm{if}\quad 0\le y\le 1$$ $$\begin{align} f_Z(z) & = \int_{-\infty}^\infty f_X(z-y)f_Y(y) dy \\ & = \int_0^1 f_X(z-y) dy \\ \end{align}$$ I don't understand the following part of the solution, specifically how the range for $z$ gets separated and the respective bounds for the integrals are determined.
The integrand is 0 unless $0\le z-y\le 1$ or $z-1\le y\le z$. So:
if $0\le z\le 1, f_Z(z) = \int_0^z dy = z$
if $1<z \le 2, f_Z(z) = \int_{z-1}^1 dy = 2-z$