Using the method of characteristics, find a solution to Burgers' equation \begin{cases} u_t+\left(\frac{u^2}{2} \right)_x =0 & \text{in }\mathbb{R}\times(0,\infty) \\ \qquad \qquad \, \, u=g & \text{on } \mathbb{R} \times\{t=0\} \end{cases} with the initial conditions $$g(x)=\begin{cases} 0 & \text{if }x < 0 \\ 1 & \text{if }0 \le x \le 1 \\ 0 & \text{if }x > 1 \end{cases}$$
First, I realized that the equation $u_t+\left(\frac{u^2}{2} \right)_x =0$ is equivalent to this form: $$u_t+uu_x =0$$
Then should I generally follow the method of solution as outlined in the answer of this page?
Note that this is not a duplicate question of that page. Rather I want to know if that page can be used for my problem, even though my ICs are different.
By the way, the solution printed in my book (PDE Evans, 2nd edition, page 142) is
$$u(x,t) = \begin{cases} 0 & \text{if } x < 0 \\ \frac xt & \text{if } 0 < x < t \\ 1 & \text{if } t < x < 1 + \frac t2 \\ 0 & \text{if } x > 1 + \frac t2 \tag{$0 \le t \le 2$} \end{cases}$$