Texts: Available from Sunday, 21 June 2020, 3:00 PM
Due date: Sunday, 21 June 2020, 5:01 PM
Requested files: main.cpp, Unit.h, Unit.cpp, Meter.h, Meter.cpp, Inch.h, Inch.cpp (Download)
Type of work: Individual work
You are asked to write Unit, Meter, and Inch classes which hold a distance value (double) and provide a convert function to convert between different units.
Unit class and header: Write an abstract Unit class which is a base of all kinds of units.
a) Unit class should have a double value "distance" which is used to store the distance measurement of a particular unit.
b) Unit class should have an abstract method "equivalentCMO" which returns a double value indicating the equivalent centimeters of a concrete unit (i.e. 1 Unit = x cm).
c) Unit class should have a static function called convert which accepts two Unit objects to convert the first unit to the second:
convert(in, out):
This statement should read the distance value in "in" object and convert it to the second unit "out" and write the result onto the distance value in "out" object.
You are provided "main.cpp" which has a test procedure. Analyze it to understand the usage of this function.
Meter class and header: Write a concrete Meter class which is a subclass of Unit. Note that 1 meter = 100 cm.
Inch class and header: Write a concrete Inch class which is a subclass of Unit. Note that 1 inch = 2.54 cm.
Note: You are provided main.cpp for testing purposes. DO NOT MODIFY IT!