For the general solution : \begin{equation} u(x,t) =\frac{1}{2}[g(x+ct)+g(x-ct)]+\frac{1}{2c}
\int_{x-ct}^{x+ct}h(y)dy
\end{equation}
$$\\
$$for part(a):
\begin{equation}
u(x,t) =\frac{1}{2}[g(x+ct)+g(x-ct)]
\end{equation}
$$
u(x,t) =
\begin{cases}
0, & \text{$x-ct >1 , x+ct \geq1$} \\
\frac{1}{2}, & \text{$\vert x-ct \vert <1 , x+ct \geq1$}\\
1, & \text{$\vert x-ct \vert <1 , \vert x+ct \vert<1$}\\
1, & \text{$x-ct <-1 , x+ct \geq1$}\\
\end{cases}
$$for part(b):
\begin{equation}
u(x,t) =\frac{1}{2c}
\int_{x-ct}^{x+ct}h(y)dy
\end{equation}
$$
u(x,t) =
\begin{cases}
0, & \text{$x-ct >\frac{\pi}{2} , x+ct >\frac{\pi}{2}$} \\
\frac{1}{2c}(1-\sin(x-ct), & \text{$\vert x-ct \vert <\frac{\pi}{2} ,x+ct \geq\frac{\pi}{2}$}\\
\frac{1}{2c}(\sin(x+ct)-\sin(x-ct), & \text{$\vert x-ct \vert <\frac{\pi}{2} , \vert x+ct \vert<\frac{\pi}{2}$}\\
\frac{1}{c}, & \text{$x-ct <-\frac{\pi}{2} , x+ct \geq\frac{\pi}{2} $}\\
\end{cases}
$$