Congratulations, you made it to the end of the course! Riverside Pool’s passes module now runs in JavaScript and prints the same nine lines as pool_passes.py. The output runs from Priya Nair (adult): ten-swim card, 3 left to On file: Tom Hale (concession): membership, 6 months, with Grace Obi on the Early Lanes waitlist in between.
In Porting the Pool Passes Module, you ported the four classes and the module’s first four lines. In the exercise Finish the Pool Passes Module, you completed it, booking the three passes onto Early Lanes and previewing Tom’s renewal on a copy. Each Python class kept its job and became what a JavaScript developer would write.
In this course, you learned how to:
- Port a class to JavaScript with a
constructorthat sets properties onthis, methods that never list the instance as a parameter, andnewat every call that makes an instance - Replace a dataclass with fields in the class body and a constructor that takes the arguments, as
Swimmerdoes withconstructor(name, group = "adult") - Keep state in a
#private field, read it through agetgetter without parentheses, and check every new value in asetsetter - Share a price and a factory with
static, as inTenSwimCard.PRICEandTenSwimCard.fromRecord() - Extend a class with
extends, callsuper(swimmer)before any use ofthis, and reach the parent’s method withsuper.checkIn() - Print instances with a
toString()method and template literals - Copy and save instances through their own methods, a
.copy()that callsnewand a.toJSON()that returns the record - Pass a method as a callback inside an arrow function,
(name) => waitlist.add(name), sothisstays the waitlist