I am designing a program for converting distances between units and have been given code to test this. I don't understand how to write my method so that is can be called by a constant. The following code is given:
System.out.println(DistanceUnit.METER.toMetric(100));
System.out.println(DistanceUnit.METER.fromMetric(100));
System.out.println(DistanceUnit.FOOT.toMetric(100));
System.out.println(DistanceUnit.FOOT.fromMetric(100));
System.out.println(DistanceUnit.PLANCK.toMetric(100));
System.out.println(DistanceUnit.PLANCK.fromMetric(100));;
System.out.println(DistanceUnit.PARSEC.toMetric(100));
System.out.println(DistanceUnit.PARSEC.fromMetric(100));
So I have defined the constants above according to the instructions in the assignment but how do I create the methods fromMetric and toMetric so that they can be called by the constants from DistanceUnits?