Project: Length Class
Write an immutable class to represent length. You will need to setup an enumeration for the different possible units of mm, cm, m, km, in, ft, yd, and mile. Pick one of the units for your internal representations and provide a private constructor that takes the length value and a unit enumeration. Then provide a static factory method that takes the same arguments and returns a length object. The factory method will store objects it creates in a map so that it can use the map to return previously cached objects that match. This helps to keep the number of objects created down. Provide toString type method that returns a reasonable representation of the length object(value plus nearest unit) in SI and one for English units.
Provide add and subtract methods that take a length object as an argument and returns the sum or difference of the calling object plus the argument object. Also provide multiply and divide methods that take a non-dimensional double argument and return a length object that is the product or quotient of the calling object and the non-dimensional double.
See See [[Unit_of_length|Unit of Length]]