Pure Programmer
Blue Matrix


Cluster Map

Project: Duration Class

Write a mutable class to represent a time duration. Your class should represent time durations in the following units: ns, µs, ms, s, min, hour, day, week, month, year. Use an enumeration to represent the time duration units. You should have a default constructor that sets the internal value to 0. Write a setter that takes a value and an enumeration value for units. Include a getter that takes an enumeration value for units and returns the value in that measurement unit.

Output
$ perl DurationClass.pl Wide character in print at DurationClass.pl line 135. Bareword "Duration::Unit::μs" not allowed while "strict subs" in use at DurationClass.pl line 35. Bareword "Duration::Unit::μs" not allowed while "strict subs" in use at DurationClass.pl line 97. Bareword "Duration::Unit::μs" not allowed while "strict subs" in use at DurationClass.pl line 110. Bareword "Duration::Unit::μs" not allowed while "strict subs" in use at DurationClass.pl line 123. Execution of DurationClass.pl aborted due to compilation errors.

Solution