observer pattern def decrease_balance(selfamount)self amount -amount def update(selfobserved)self increase_balance( def __str__(self)return str(self amountclass badge(object)def __init__(selfname_type)self points self name name self _type _type self awarded false def add_points(selfamount)self points +amount if self points self awarded true def update(selfobserved)if observed _type =self _typeself add_points( def __str__(self)if self awardedaward_string "earnedelseaward_string "unearnedreturn "{}{[{}]formatself nameaward_stringself points