π¨ Open
and work through each section. There are
no automated tests hereβuse the examples below as your success criteria.
Section 1: Class Basics
Product.getDescription()returns{name}: ${price}(example:Mug: $12)ShoppingCartstarts empty;addItemappends;getTotalsums prices- Example: Mug
12+ Notebook8β total20
Section 2: Private Fields & Defaults
BankAccountstarts at balance0when constructed with no argsdeposit/withdrawchange balance;getBalancereturns it- Example: deposit
50, withdraw10β balance40 Configdefaults:host = 'localhost',port = 3000,role = 'user'
Section 3: Interfaces
CreditCard.pay(25)βPaid $25 with card 1234(for card'1234')PayPal.pay(25)βPaid $25 with PayPal user@example.com
Section 4: Programming to Abstractions
processPayment(method, amount)returns that method's payment result for the amountGiftCardwith code'GC-001':pay(40)βPaid $40 with gift card GC-001
Section 5: Inheritance
Package.getLabel()β{label} ({weight}kg)- Example:
new Box('Box A', 5, 10).getLabel()βBox A (5kg) - Example:
new Crate('Crate B', 20, 'wood').getLabel()βCrate B (20kg)
Section 6: Method Overriding
Shape.getArea()β0new Circle(2).getArea()is about12.57(Ο Γ radiusΒ²)new Rectangle(3, 4).getArea()β12
Section 7: Substitutability
MediaPlayer.playFileacceptsMediaFileand returns that file's play result- Audio example:
Playing audio song.mp3 - Video example:
Playing video movie.mp4
Section 8: Composition & Dependency Injection
Logger.log(message)returns the prefixed stringLog: {message}InMemoryLoggerstores the rawmessageargument (not the prefixed return value);getLogs()returns a copy of those stored messagesReportService.generateReport('Weekly Summary')calls the injected logger withReport: Weekly Summary- After that call with an
InMemoryLogger,getLogs()includesReport: Weekly Summary(the argument that was logged)