added protection for setWeight method in Dog class