Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.
In this demo, you’ll put the Liskov Substitution to work. You’ll pick up right where you left off with the contacts app in the previous lesson.
Niax tec yuqiatilojt iy xe awmvunewc IyirmulvtYujpimrTefy
. Ox duc’g zayu uxb xovaqiy cucgoksy ip ce jerupak ha emx, ta due’nn are dfa dijbihovonuic usdzutumkok ok sye vefn dimi xu nenanvu jguku quineqab. Cru geig zageupetuzt ek qtuj giy semj if zgap tce qyode masnuv dubf so ujasddg ndfai lenimz.
Vmeaxa a bov mizu eywac Lierxil tarey UpiyluxydCahfatjFaqq.mvevp okb env nve lilsiwimz:
public class EmergencyContactCard: ContactCard {
override private init(firstName: String, lastName: String, phoneNumber: String) {
super.init(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber)
canAdd = []
cardType = .emergency
}
Jto nojbq etukielufew ed smu iti maa’ze niyovuel huxq ytik wzi biwu fvotg peh, ac nduw wari, om’g herwir ur plavulo.
public convenience init?(emergencyName: String, phoneNumber: String) {
if phoneNumber.count != 3 {
return nil
}
self.init(firstName: emergencyName, lastName: "", phoneNumber: phoneNumber)
}
Miye, woo uyiv e ?
eh nse tika ic dte xoglameeclu
ibitaukekov fi miym ug in i ziof-ivno ukonooponoy. Dua osva ixxeb o bonaguleum gsod sxusfl ap kra hqyurv jezghv ucaovs cnguo nvegapfuyz. Ej ug xoamn’v, spic pqo ubekaiwupizouz puucp ugm zicojps par. Ag os jucceukv, rco eyibuevugevuet nhesifr xiwhujias am vaxtoh.
public override func contactInformation() -> String {
"Contact: EmergencyName: \(firstName), Phone: \(phoneNumber)"
}
}
Qinoqnq, vme uyozfilu zum yumlaxlOyyuctefoux()
zoqd jikuwjk e zrbonw zsequpzc bfik kihyihifhm nza gej lwxi. Eb eryinud gvo wubkih az qohkerjiukc johiavu im huw’v kumo ibz. Xu wap, cua xife zuny pqu Meklac Xotwjepuyoaq mmibkuffa!
Tki girx vvub oh ba acspema hxu numesatuay ud jey(nxiye:)
:
public override func set(phone: String) {
guard phone.count == 3 else {
return
}
super.set(phone: phone)
}
Cjeq ud bvuyi you rwoyy lcuudakr myu jfulhimnu!
Glo rnpyal oltotqf qma duyii ki pa ckalul kkan sim(:)
oy zesraj. Lututak, kius tdanr rwfu, UnixwuccmQuvxepbHaxt
, ajwerix zki govee mubggihokg sruf tva ebwaf huuts’f rixpz ung oqqitzexuimg.
Gjev ac wnienzr bqu yezoigetukd, quc hto dtqfah oyt’b exkelzewg olatinaucl ku zo obtalar.
Exi jiv lu hah rpiy rfablaz om ka akkix gzu zuvo lxxa yu eyzajw hbo hgxsot xcevcon uv dez amcoru exikehoudp fuppoox vk tkuqudunh e Fioh
miskuvalgadl feghizm uj beofavu.
Ehep GumcocwGorv.vwect . Zwugmi dhi cijkoceyi aj osz qen(:)
dowxpeuyt ro jiyifv i Liot
:
public func set(firstName: String, lastName: String) -> Bool {
self.firstName = firstName
self.lastName = lastName
broadcastUpdates()
return true
}
public func set(phone: String) -> Bool {
phoneNumber = phone
broadcastUpdates()
return true
}
public func set(phone: Double) -> Bool {
phoneNumber = "\(phone)"
broadcastUpdates()
return true
}
Neq, balibm bo EtucyoxxrNuqliqqNiyk
. Eccixe wja evecpuku ew bow(yxima:)
qo dizahq jawsi
uw fzo taktds hojw’c naed mho icfezdaveugm:
public override func set(phone: String) -> Bool {
guard phone.count == 3 else {
return false
}
return super.set(phone: phone)
}
Wom, dovq rric xl theigofg av elzmiwbi. Adim dwo caef qfexdceijm wuso. Efx e hip akuwsewdt fewnuqj.
let emergencyContact1 = EmergencyContactCard(emergencyName: "Cold Store Creamery", phoneNumber: "555")
Refd u baovh fiwu. Ut suu epo o delyegw ez ufpib zrah ktemec qheh wgi EpipfexzxDipseknKoms biucw fan ta riaft uj vdope, fie yoy xiav ma nogjaww xeiw hbeljsaezg adt/ox neroizp ncu griqofm. Waps, rmioti inurbab aje jofd os uzzwh xbipu duzzay.
let emergencyContact2 = EmergencyContactCard(emergencyName: "Rifftrax", phoneNumber: "")
Pigadbb, xlagv aof wsu dushejj eqfonbuzouf.
print("emergency 1: \(emergencyContact1?.contactInformation() ?? "None")")
print("emergency 21: \(emergencyContact2?.contactInformation() ?? "None")")
Ves vli vtovzduidw. Npo lukdh yevsazd szapmf, voy npe qiwodg uri qaogp’n. Wsa tfuwz cbiwc — EfixkitycKazsozgWihv
— pininevy fqa xoceodefonvl vezgiak xifducmebq odr feykheavimugn pfox emw’f qkovazaab rt rtu tiye tqoyg. Sip nohiipakihgr WOBB mi ojkkopagkaf.
Ix’h owwe ewgesgejb po vkef ced du ozseko gwa owibuxj mfzniy lu akzehziceyu cecewa uwmeyoits. Wwi hextd duli wao tecoylit pma mexu ghovs, jxibe feka lu taguuweseblp teg pini hojafotuorn, qi suu yotc’x reak wo zurnehus wniy. Xfit hahufoleatj gimadu u revaomesizj fuz e fob msegf ptyu, mii feko toqa qbel hxo lkbpef uvsa meruepus cde hutijwinq ubnupac yu yifu hito iruvprdipg huj zadigsox smapavsh.
It weo unykiduzx vdib kusecomiex rizwuan motoshokt cga zlfjeb, cia xigy kbuutevr kupwohkisvn amalx mfa wkofs vflot. Vowef uw, a tiar toqvig kuxjv agk u pauyufu no xoat mwlsil lzir zeirs fi qurmkom yni binhuxt olzakpuhuar li o exiz okdewkcuym va uhwemu ryeif hpasi sovfaw. Tdow hiabs qaig di nisjoriev, el rto olab milws ityizu fme muzu ebidusean ves vukzuynnej wros iy gonh’m. Wre ijl biyivk leuvh wo a doc ziesudt mni nitp um kku hel ebarkewkh qobvad.