Program 29
Write a class called Converter. The user will pass a length and a
unit when declaring an object from the class—for example, c =
Converter(9,'inches'). The possible units are inches, feet, yards, miles,
kilometers, meters, centimeters, and millimeters. For each of these units there
should be a method that returns the length converted into those units. For
example, using the Converter object created above, the user could call c.feet()
and should get 0.75 as the result.
No comments:
Post a Comment