encapsulation by the conventions described in section single leading underscore in the name of data membersuch as balanceimplies that it is intended as nonpublic users of class should not directly access such members as general rulewe will treat all data members as nonpublic this allows us to better enforce consistent state for all instances we can provide accessorssuch as get balanceto provide user of our class read-only access to trait if we wish to allow the user to change the statewe can provide appropriate update methods in the context of data structuresencapsulating the internal representation allows us greater flexibility to redesign the way class worksperhaps to improve the efficiency of the structure additional methods the most interesting behaviors in our class are charge and make payment the charge function typically adds the given price to the credit card balanceto reflect purchase of said price by the customer howeverbefore accepting the chargeour implementation verifies that the new purchase would not cause the balance to exceed the credit limit the make payment charge reflects the customer sending payment to the bank for the given amountthereby reducing the balance on the card we note that in the commandself balance -amountthe expression self balance is qualified with the self identifier because it represents an instance variable of the cardwhile the unqualified amount represents the local parameter error checking our implementation of the creditcard class is not particularly robust firstwe note that we did not explicitly check the types of the parameters to charge and make paymentnor any of the parameters to the constructor if user were to make call such as visa chargecandy )our code would presumably crash when attempting to add that parameter to the current balance if this class were to be widely used in librarywe might use more rigorous techniques to raise typeerror when facing such misuse (see section beyond the obvious type errorsour implementation may be susceptible to logical errors for exampleif user were allowed to charge negative pricesuch as visa charge(- )that would serve to lower the customer' balance this provides loophole for lowering balance without making payment of coursethis might be considered valid usage if modeling the credit received when customer returns merchandise to store we will explore some such issues with the creditcard class in the end-of-exercises