Maximum Likelihood Estimate for a likelihood defined by parts 
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. 
 A: The likelihood writes down as
$$\prod_{i;\,x_i\le\theta/2} \frac{4x_i}{\theta^2}
  \prod_{i;\,\theta/2<x_i\le\theta} \frac{4\theta-4x_i}{\theta^2}$$
that is
$$4^n\theta^{-2n}\prod_{i;\,x_i\le \theta/2}x_i\prod_{i;\,\theta/2<x_i\le\theta} (\theta-x_i)$$
Thus relabelling the observations as $x_1<x_2<\ldots<x_n$, it is
\begin{cases}
4^n\theta^{-2n}\prod_{i=1}^n x_i &\text{when }\theta/2>x_n\\
4^n\theta^{-2n}\prod_{i=1}^{n-1} x_i (\theta-x_n) &\text{when }x_{n-1}<\theta/2<x_n<\theta\\
\qquad\vdots &\\
4^n\theta^{-2n}\prod_{i=1}^2 x_i\prod_{i=3}^n(\theta-x_i) &\text{when }x_3>\theta/2>x_2\vee x_n/2\\
4^n\theta^{-2n} x_1\prod_{i=3}^n(\theta-x_i) &\text{when }x_2>\theta/2>x_1\vee x_n/2\\
4^n\theta^{-2n}\prod_{i=1}^{n} (\theta-x_i) &\text{when }x_n/2<\theta/2<x_1
\end{cases}
For $n=2$, this simplifies into
\begin{cases}
4^2\theta^{-4}\prod_{i=1}^2 x_i &\text{when }\theta/2>x_2\\
4^2\theta^{-4}x_1 (\theta-x_2) &\text{when }x_{1}\vee x_2/2<\theta/2<x_2<\theta\\
4^2\theta^{-4}\prod_{i=1}^{2} (\theta-x_i) &\text{when }x_2/2<\theta/2<x_1
\end{cases}
If $x_2>2x_1$ this further simplifies into
 \begin{cases}
4^2\theta^{-4}\prod_{i=1}^2 x_i &\text{when }\theta/2>x_2\\
4^2\theta^{-4}x_1 (\theta-x_2) &\text{when }x_{2}<\theta<2x_2\\
\end{cases}
The first function of $\theta$ is maximised at the lower bound $\theta=2 x_2$ with value
$$x_2^{-4}\prod_{i=1}^2 x_i=\frac{x_1}{x_2^3}$$
The second function of $\theta$ leads to the derivative
$$\frac{-3}{\theta^4}+\frac{4x_2}{\theta^5}=\frac{4x_2-3\theta}{\theta^5}$$
which is positive iff $\theta\le 4x_2/3$. Hence the second
function of $\theta$ is maximised at $\theta=4x_2/3$ which stands within the interval $(x_2,2x_2)$, with value
$$4^2 (4x_2/3)^{-4} x_1 (x_2/3) = \frac{3^3 x_1}{4^2 x_2^3}$$
Since $3^3/4^2=1.6875>1$, the optimum of the function is achieved for $\theta=4x_2/3$. Which can be checked by plotting the likelihood function

