You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 1320xx51-3
// let reFormula = try! NSRegularExpression(pattern: "^20\\d{2}[1-3]\\d{8}$", options: [NSRegularExpression.Options.anchorsMatchLines])
// let matchRange = NSRange(ID.startIndex..<ID.endIndex, in: ID)
// let matchList = reFormula.matches(in: ID, range: matchRange)
// if matchList.count != 1 {
// return false
// }
// return true
// ID 13
// let reFormula = try! NSRegularExpression(pattern: "^\\d{13}$", options: [NSRegularExpression.Options.anchorsMatchLines])
// let matchRange = NSRange(ID.startIndex..<ID.endIndex, in: ID)
// let matchList = reFormula.matches(in: ID, range: matchRange)
// if matchList.count != 1 {
// return false
// }
// return true
// ID 130000
// let reFormula = try! NSRegularExpression(pattern: "^0000\\d{9}$", options: [NSRegularExpression.Options.anchorsMatchLines])
// let matchRange = NSRange(ID.startIndex..<ID.endIndex, in: ID)
// let matchList = reFormula.matches(in: ID, range: matchRange)
// if matchList.count != 1 {
// return false
// }
// return true
//
var fly = Entity()
fly.ID = "0000000099003"
fly.name = "蒼蠅"
fly.verify()
var siuming = Student()
siuming.ID = "2021502233076"
siuming.name = "小明"
siuming.verify()
var siuhung = Student()
siuhung.ID = "2022302191000"
siuhung.name = "小紅"
siuhung.verify()
var policecat = Cat()
policecat.ID = "0000999988222"
policecat.name = "警長"
policecat.verify()