Implementation details aren??™t provided because different
entities might need to implement the published method definitions in different
ways. The point is to establish a general set of guidelines that must be implemented
in order for the interface to be considered implemented.
?– Caution Class members are not defined within interfaces. This is a matter left entirely to the implementing
class.
Take for example the concept of pillaging a company. This task might be accomplished
in a variety of ways, depending on who is doing the dirty work. For example,
a typical employee might do his part by using the office credit card to purchase shoes
and movie tickets, writing the purchases off as ???office expenses,??? while an executive
might force his assistant to reallocate funds to his Swiss bank account through the
online accounting system. Both employees are intent on accomplishing the task, but
204 CHAPTER 7 ?– ADVANCED OOP FEATURES
each goes about it in a different way. In this case, the goal of the interface is to define
a set of guidelines for pillaging the company and then ask the respective classes to
implement that interface accordingly. For example, the interface might consist of just
two methods:
emptyBankAccount()
burnDocuments()
You can then ask the Employee and Executive classes to implement these features. In
this section, you??™ll learn how this is accomplished.
Pages:
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282