rewrite the python program to class