Wrote code for Preference class