Exercise 2: Why INHERITS Gives Access to IS-VALID-BALANCE With No Rewriting or Copying — Possible Solution ==================================================================== WHAT INHERITS GENUINELY DECLARES This chapter's own real example, CLASS-ID. PREMIUM-CUSTOMER-VALIDATOR INHERITS CUSTOMER-VALIDATOR, establishes a real relationship directly on the new class's own definition line: PREMIUM-CUSTOMER-VALIDATOR is declared as a genuine extension of CUSTOMER-VALIDATOR, the class that already contains the real IS-VALID-BALANCE method. WHY THIS IS DIFFERENT FROM COPYBOOK-STYLE TEXTUAL INCLUSION Chapter 2's own real COPY mechanism works by textually substituting a copybook's own source directly into an including program before compilation - the copied text becomes a permanent, separate part of each including program's own compiled form. INHERITS works differently: it doesn't copy IS-VALID-BALANCE's own source code into PREMIUM-CUSTOMER-VALIDATOR at all. Instead, it establishes a genuine real relationship between two distinct classes, letting the new class draw on the original class's own already-compiled method directly. WHY THE METHOD DOESN'T NEED REWRITING OR COPYING AT ALL Because CUSTOMER-VALIDATOR's own IS-VALID-BALANCE method already exists, fully written and compiled, declaring INHERITS simply gives PREMIUM-CUSTOMER-VALIDATOR real access to that same existing method - the real logic checking whether a balance is negative doesn't need to be typed out again inside PREMIUM-CUSTOMER-VALIDATOR's own definition. This is precisely the real point of class inheritance as a concept: a new class can genuinely reuse a parent class's own real capabilities without duplicating their underlying implementation. WHY THIS MATTERS PRACTICALLY, THE SAME WAY COPYBOOKS DID This mirrors the same real value Chapter 2 established for copybooks - avoiding one real piece of logic needing to be maintained in multiple separate places - but achieved through a genuinely different real mechanism. A copybook's own text is duplicated into every including program at compile time; an inherited method, by contrast, continues to exist in exactly one place, the parent class, with the subclass simply gaining real access to it rather than acquiring its own separate copy. ANSWER: PREMIUM-CUSTOMER-VALIDATOR INHERITS CUSTOMER-VALIDATOR establishes a genuine real relationship between the two classes, letting the new subclass draw directly on CUSTOMER-VALIDATOR's own already-existing, already-compiled IS-VALID-BALANCE method rather than requiring that method's own logic to be rewritten or copied into the new class. This is structurally different from Chapter 2's own COPY mechanism, which duplicates a copybook's actual text into every including program - inheritance instead lets IS-VALID-BALANCE continue to exist in exactly one place, the parent class, while the subclass genuinely gains access to use it. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly explains inheritance as a real relationship granting access to an existing method rather than a textual-duplication mechanism, and draws an explicit, accurate contrast against Chapter 2's own genuinely different COPY-based reuse approach.