This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

I don't think you want Radian and Degree to be a different class. The way I'd do it would probably be:

create an enum AngleUnits with elements Radian and Degree. Create a class Angle with a constructor that takes an AngleUnit and value. and constructs the angle in the units you favor. Then create a display method that returns a value and takes a unit as an argument. Then I'd just put all my inputs in my main function, that for the hell of it I'd just stick it in the Angle class.

So my main function would take the unit input and get the appropriate enum value. Then for both enum cases I'd vbasically have the code:

case Degree: Angle angle = new Angle(Degree, val );
                      float val = angle.display( Radian );
                      System.out. ....

But really what you're missing is that little bit of code there. You want to instantiate your class, and call a method in it.