class Student {
let name:String = “刘”
func study() {
print(“实现方法”)
}
}
let le = Student.init()
le.study()
class Middle_School_Student: Student {
var score:Double = 98.0
override func study() {
print(“重写父类”)
super.study()
}
}
class University_Student: Student {
var zhuan:String = “移动”
override func study() {
print(“重写”)
super.study()
}
}
let mid = Middle_School_Student.init()
let uni = University_Student.init()
mid.study()
uni.study()
//定义一个字符串str1,内容为自己姓名的全拼,在str1的后面连接上自己的年龄,生成第二个字符串str2
var str1 = “liuxinquan”
print(str1)
var str2 = str1+“18”
print(str2)
//打印出str2的长度,比较这两个字符串的大小关系
print(str2.count)
if(str1 > str2){
print(“str1 大于 str2”)
}else{
print(“str1 小于 str2”)
}
//比较这两个串是否相等,并打印相应的结果,求str2的长度
if(str1 == str2){
print(“str1 等于 str2”)
}else{
print(“str1 不等于 str2”)
}
//将str1的第一个字符,替换成大写字符,并生成str3
var str3 = NSString(string:str1)
print(str3.capitalized)
str2 = str2.replacingOccurrences(of: “18”, with: “100”)
print(str2)
var nnn:String = “八维校刊”
for asd in nnn.reversed(){
print(asd, terminator:"")
}