If you begin with a random variable Y that is uniformly distributed on the interval (-2,1), then it is reasonable to think of Y as a randomly chosen point. Then by definition X=|Y|, Y’s distance from zero. Now one characterization of continuous random variable is: the range of the variable includes an interval of real numbers, bounded or unbounded. The range of X is [0,2).
Assuming that I am correct about Y being uniformly distributed on the interval (-2,1), and X=|Y| then the density function is a bit hard to see.
Consider this:
You may want to check out the integral of f(x) over [0,2] to see how it all works.
In particular, you want use the integral of xf(x) to find the mean.