finished encoding class and demo program