12.07.2015 Views

OO Example: Fractions

OO Example: Fractions

OO Example: Fractions

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Set/get (mutator/accessor) We have hidden the attributes __numer and__denom from direct access by other programs We can give them read or write access to thoseattributes, but only through our methods:● Get method (accessor): def get_N():● Set method (mutator): def set_N(): This way we can do safety checking,e.g., check if denom is being set to 0 Potentially: security/permissions,who is modifying this attribute, logging, etc.CMPT140: <strong>OO</strong>: fractions 20 Nov 20096

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!