Suppose $X_1$, . . . , $X_n$ are i.i.d random variables having pdf
$$ f(x\mid\theta)= \begin{cases} \frac{4}{\theta}-\frac{4x}{\theta^2} & \frac{\theta}{2} \lt x \lt \theta \\ \frac{4x}{\theta^2} & 0 \lt x \leq \frac{\theta}{2} \\ 0 & \text{otherwise} \end{cases} $$
where $\theta\in(0,\infty)$.
(a) Give a method of moments estimator of $\theta$
(b) For the case of $n= 2$, $x_1= 10$, and $x_2= 4.5$, give the maximum likelihood estimate of $\theta$.
My Attempt:
(a) I have that
$$\mathsf E(X)=\int_0^{\frac{\theta}{2}} \frac{4x^2}{\theta^2}dx+\int_{\frac{\theta}{2}}^{\theta} \frac{4x}{\theta}-\frac{4x^2}{\theta^2}dx=\frac{\theta}{2}$$
Hence
$$\mu_1'=\frac{\theta}{2}\Rightarrow \theta=2\mu_1'\Rightarrow \hat{\theta}_{MME} = 2\bar{x}$$
Is this a valid solution?
(b)
I'm not quite sure how to find the MLE since this is a piecewise function. The usual case I have dealt with is where
$$L(\theta\mid \vec{x})=f(\vec{x}\mid\theta)$$
and you just take the product of the individual densities.
I have in this case that the likelihood function is given by
$$L(\theta∣x_1,x_2)=\prod_{i=1}^2\left[\left(\frac{4}{\theta}−\frac{4x_i}{\theta^2}\right)I_{(\theta/2,\theta)}(x_i)+\frac{4x_i}{θ^2}I_{(0,\theta/2)}(x_i)\right]$$
One thing I notice is that since $x_1= 10.0$, and $x_2= 4.5$ it cannot be the case that $x_1$ and $x_2$ are both in $\left(\frac{\theta}{2},\theta\right)$. I also note that the only way $x_1, x_2\in\left(0,\frac{\theta}{2}\right)$ is if $\theta\gt20$. Could I somehow use these facts to get the likelihood on a case-by-case basis where either$$x_1,x_2\in\left(0,\frac{\theta}{2}\right)$$ or $$x_2\in\left(0,\frac{\theta}{2}\right)$$ $$x_1\in\left(\frac{\theta}{2},\theta\right)$$
My concern with going this route is that the probability that one of these two events occurs depends on $\theta$. Any hints to get me going in the right direction would be much appreciated.