Question by
mahdiii · Jul 27, 2016 at 11:25 AM ·
interfaceenumif statementinterfacesenumerate
Interfaces vs methods selection using if(enumerations)
Hi all. I want to know which is better. For example I have a script that implements different move methods(linear,Constant,sagittal,polynomial ,etc) I can implement all of them in one script and select every of them by if statements.
public enum Move_type{ constant,linear,polynomial } public class Generic_move{ public Move_type move_type; public void move(){ if(move_type==Move_type.constant){ ... } else if(){ ... } } } or I can implement an interface and multiple scripts for each move methods. public interface IMovable{ move(); }
public Class linear_move{ public move(){ } }
public Class constant_move{ public move(){ } }
plz say which is better and when we need to use interfaces thx.
Comment