Andsowhenweincreasethewidthfrom 10 to 11 wegetanareaof 20 towhichweseeprintedontheright.
Andhere, whenweincreasethewidthfrom 5 to 6, wegetanareaof 30 whichisshowingoverhere.
Butyoumaynoticethatthisrectanglerighthereisactually a square.
Soweshouldjustchangethistobe a squarechangerectangletotojustbesquareandwecancomeandreplaceallof a rectangletwo's withsquareandweshouldseetheexactsamethinghappen.
Everythingisgonnabethesameoverhere, right?
22 30 becausewe'renowcallingthisincreasedrectanglewithwith a square, whichis a subclassofrectangle.
I haveanotherexamplethat I'm gonnajumptoweakenshowexactlyanotherwaythattheScotssubstitutionprinciplewasviolatedandhowwecanactuallyfixit.
Sohere I haveanotherexampleofthelistcoughsubstitutionprincipalandwehavethreedifferentclassesarefirstclassisourbaseclass, whichis a bird, andallofourbirdscanflybecausebirdscanfly.
Sowehave a fivefunctiononourbird.
Ournextclassis a duckclasswhichextendsbirdbecauseitis a birdandhas a quackfunctionbecauseducksquack.
Andthenlastly, wehave a penguinfunctionor a penguinclass, whichextendsbirdbecause a penguinis a birdandpenguinscan't fly.
Sowe'rethrowinganairsaying, Hey, wecan't fi.
Wecan't actuallydothis, Butwealsohave a swimfunctionbecausepenguinscanswim.
Soitsays I canswimandtheninsideofherewehave a makebirdflyfunctionwhichjustcallsflyon a birdandthenwe'recreatingtwodifferentbirdsduckandpenguin, andthenwe'remakingthemfly.
Andasyoucansee, theduckprintsout.
I canflyjustfine.
Butthepenguinisthrowinganairsayingitcannotfly.
Andthisisagainanotherinstanceofthelistcoughsubstitutionprinciplenotworkingbecausethisis a birdfunction.
Soitexpects a birdclass, andwe'repassinginbothofthesubclasses a bird, duckandpenguin.
Andaccordingtotheprinciple, everysubclassof a classmustbeabletomakethisfunctionworkproperly.
Costsubstitutionprincipleandaneasywaytofixthisistochangeitsothatwedon't justhave a birdsubclassWehave a flyingbirdsomeclass.
Sowe'regonnasaywe'regonnahaveflyingbirds, andourduckisgoingtoextendfromflyingbirdandthenwe'realsogoingtocreate a swimmingthatbirdandthenwe'regoingtoputourswimmethodinsideofthere.
Solet's justcopythatpastethatintoourswimmingbird.
Andofcourse, sinceourpenguincanswim, itisgoingtobe a swingbird.
Wedon't needtoworryaboutthisfivefunctionanymore.
Nowwecandoiswecanmake a flyingbirdfly.
Wecanhaveanotherfunctionwhichisgoingtomake a babyswimming, makeswimmingbirdswimandthenwe'rejustgonnacallswimhere.
Sonowwecansaymakeflyingverytoflyonourduckandwecanmake a swimmingbirdswimonourpenguinandyoucanseethatworks.
Forexample, allyouneedtoknow, though, forthelistcoughsubstitutionprincipleisthatifyouhave a functionthataccepts a class, everysinglesubclassofthatclassmustalsobeabletoenterthatfunctionandworkproperlyasallthereistothelistgotsubstitutionprinciple.