commit 02f98de3220d0086ca11c9cd89761856e2563d49 Author: ostrichb Date: Sat Nov 12 03:23:56 2022 +0000 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..135767f --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/Task1_practice.playground/Contents.swift b/Task1_practice.playground/Contents.swift new file mode 100644 index 0000000..9d2e048 --- /dev/null +++ b/Task1_practice.playground/Contents.swift @@ -0,0 +1,26 @@ +import Foundation + +// Write your code here... + +func varProcessor(_ n: Any) { + let nInt = n as? Int ?? 0 // 如果n是整形数,nInt将会被赋予n的值 + let nString = n as? String ?? "" // 如果n是字符串,nString将会被赋予n的值 + switch n { + case is Int: + // 如果n是整形,这里的代码将会被执行 + // Write your code here... + case is String: + // 如果n是字符串,这里的代码将会被执行 + // Write your code here... + default: + print("An error occurred.") + } +} + +// 测试用,不需要改动 + +let test: [Any] = [0, 2, 0.2, "Hello"] + +for item in test { + varProcessor(item) +} diff --git a/Task1_practice.playground/contents.xcplayground b/Task1_practice.playground/contents.xcplayground new file mode 100644 index 0000000..1c968e7 --- /dev/null +++ b/Task1_practice.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Task1_practice.playground/playground.xcworkspace/contents.xcworkspacedata b/Task1_practice.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca3329e --- /dev/null +++ b/Task1_practice.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Task1_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate b/Task1_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..f7e3165 Binary files /dev/null and b/Task1_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Task1_practice.playground/timeline.xctimeline b/Task1_practice.playground/timeline.xctimeline new file mode 100644 index 0000000..8eef80a --- /dev/null +++ b/Task1_practice.playground/timeline.xctimeline @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Task2_pracitce.playground/Contents.swift b/Task2_pracitce.playground/Contents.swift new file mode 100644 index 0000000..b339d7c --- /dev/null +++ b/Task2_pracitce.playground/Contents.swift @@ -0,0 +1,22 @@ +import Foundation + +func varProcessor(_ n: Any, /* Write your code here */) { + let nInt = n as? Int ?? 0 // 如果n是整形数,nInt将会被赋予n的值 + let nString = n as? String ?? "" // 如果n是字符串,nString将会被赋予n的值 + switch n{ + case is Int: + // 如果n是整型,这里的代码将会被执行 + // Write your code here... + case is String: + // 如果n是字符串,这里的代码将会被执行 + // Write your code here... + default: + print("An error occurred.") + } +} + +let test: [Any] = [0, 2, 0.2, "Hello"] + +for item in test { + varProcessor(item, /* Write your code here */) +} diff --git a/Task2_pracitce.playground/contents.xcplayground b/Task2_pracitce.playground/contents.xcplayground new file mode 100644 index 0000000..1c968e7 --- /dev/null +++ b/Task2_pracitce.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Task2_pracitce.playground/playground.xcworkspace/contents.xcworkspacedata b/Task2_pracitce.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca3329e --- /dev/null +++ b/Task2_pracitce.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Task2_pracitce.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate b/Task2_pracitce.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..4523bf6 Binary files /dev/null and b/Task2_pracitce.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Task2_pracitce.playground/timeline.xctimeline b/Task2_pracitce.playground/timeline.xctimeline new file mode 100644 index 0000000..f2b0fe7 --- /dev/null +++ b/Task2_pracitce.playground/timeline.xctimeline @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Task2_pracitce.playground/xcuserdata/ostrichb.xcuserdatad/xcschemes/xcschememanagement.plist b/Task2_pracitce.playground/xcuserdata/ostrichb.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..39eaece --- /dev/null +++ b/Task2_pracitce.playground/xcuserdata/ostrichb.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,16 @@ + + + + + SchemeUserState + + Task2_pracitce (Playground).xcscheme + + isShown + + orderHint + 0 + + + + diff --git a/Task3_practice.playground/Contents.swift b/Task3_practice.playground/Contents.swift new file mode 100644 index 0000000..49abc89 --- /dev/null +++ b/Task3_practice.playground/Contents.swift @@ -0,0 +1,14 @@ +import Foundation + +struct Entity { + // Write your code here +} + +// 以下的内容将能够判断名为 ID 的字符串是否满足13位数字的情况,可以直接照搬 +// let reFormula = try! NSRegularExpression(pattern: "^\\d{13}$", options: [NSRegularExpression.Options.anchorsMatchLines]) +// let matchRange = NSRange(ID.startIndex.. + + + \ No newline at end of file diff --git a/Task3_practice.playground/playground.xcworkspace/contents.xcworkspacedata b/Task3_practice.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca3329e --- /dev/null +++ b/Task3_practice.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Task3_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate b/Task3_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..ba6d53a Binary files /dev/null and b/Task3_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Task3_practice.playground/timeline.xctimeline b/Task3_practice.playground/timeline.xctimeline new file mode 100644 index 0000000..255d579 --- /dev/null +++ b/Task3_practice.playground/timeline.xctimeline @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/Task4_practice.playground/Contents.swift b/Task4_practice.playground/Contents.swift new file mode 100644 index 0000000..b010ab3 --- /dev/null +++ b/Task4_practice.playground/Contents.swift @@ -0,0 +1,68 @@ +import Foundation + +class Entity { + // Write your code here + func verify() -> Bool { + // Write your code here + } +} + +class Student: Entity { + override func verify() -> Bool { + // Write your code here + } +} + +class Cat: Entity { + override func verify() -> Bool { + // Write your code here + } +} + +// 以下的内容将能够判断名为 ID 的字符串是否满足13位数字,以20xx开头,第5位为1-3的情况,可以直接照搬 +// let reFormula = try! NSRegularExpression(pattern: "^20\\d{2}[1-3]\\d{8}$", options: [NSRegularExpression.Options.anchorsMatchLines]) +// let matchRange = NSRange(ID.startIndex.. + + + \ No newline at end of file diff --git a/Task4_practice.playground/playground.xcworkspace/contents.xcworkspacedata b/Task4_practice.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca3329e --- /dev/null +++ b/Task4_practice.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Task4_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate b/Task4_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..5e9ee24 Binary files /dev/null and b/Task4_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Task4_practice.playground/timeline.xctimeline b/Task4_practice.playground/timeline.xctimeline new file mode 100644 index 0000000..a3965cf --- /dev/null +++ b/Task4_practice.playground/timeline.xctimeline @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/Task4_practice.playground/xcuserdata/ostrichb.xcuserdatad/xcschemes/xcschememanagement.plist b/Task4_practice.playground/xcuserdata/ostrichb.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..227c1fb --- /dev/null +++ b/Task4_practice.playground/xcuserdata/ostrichb.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,16 @@ + + + + + SchemeUserState + + Task4_practice (Playground).xcscheme + + isShown + + orderHint + 0 + + + + diff --git a/Task5_practice.playground/Contents.swift b/Task5_practice.playground/Contents.swift new file mode 100644 index 0000000..f50ef01 --- /dev/null +++ b/Task5_practice.playground/Contents.swift @@ -0,0 +1,51 @@ +import Foundation + +// 把 task 4 得成果贴过来,在 task 4 的基础上继续往下写 + +// 以下的内容将能够判断名为 ID 的字符串是否满足13位数字,以20xx开头,第5位为1-3的情况,可以直接照搬 +// let reFormula = try! NSRegularExpression(pattern: "^20\\d{2}[1-3]\\d{8}$", options: [NSRegularExpression.Options.anchorsMatchLines]) +// let matchRange = NSRange(ID.startIndex.. + + + \ No newline at end of file diff --git a/Task5_practice.playground/playground.xcworkspace/contents.xcworkspacedata b/Task5_practice.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ca3329e --- /dev/null +++ b/Task5_practice.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Task5_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate b/Task5_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..8b82800 Binary files /dev/null and b/Task5_practice.playground/playground.xcworkspace/xcuserdata/ostrichb.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Task5_practice.playground/timeline.xctimeline b/Task5_practice.playground/timeline.xctimeline new file mode 100644 index 0000000..f01073e --- /dev/null +++ b/Task5_practice.playground/timeline.xctimeline @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + +