// 定义图书属性类
class BookClass{
var Bookcls = ""
var BookName = ""
var Price = 0.0
}
// 实例化5个BookClass类的对象
let objBookA = BookClass()
let objBookB = BookClass()
let objBookC = BookClass()
let objBookD = BookClass()
let objBookE = BookClass()
// 创建数组
var ArrayBook = [Any]()
// 初始化对象
objBookA.Bookcls = "励志"
objBookA.BookName = "钢铁人"
objBookA.Price = 45.0
objBookB.Bookcls = "文学"
objBookB.BookName = "小王子"
objBookB.Price = 35.7
objBookC.Bookcls = "小说"
objBookC.BookName = "平凡世界"
objBookC.Price = 40.0
objBookD.Bookcls = "少儿"
objBookD.BookName = "三毛儿"
objBookD.Price = 47.9
objBookE.Bookcls = "科技"
objBookE.BookName = "探索"
objBookE.Price = 77.0
// 将五个对象添加到数组中
ArrayBook = [objBookA,objBookB,objBookC,objBookD,objBookE]
// 打印数组里面所有对象的内容
print(ArrayBook)
// 打印价格最贵的图书的信息
print("最贵的图书信息为:分类:\(objBookE.Bookcls),书名:\(objBookE.BookName),价格:\(objBookE.Price)")
// 打印objBookC.Bookcls == “小说”的图书的信息
print("小说的图书信息为:分类:\(objBookC.Bookcls),书名:\(objBookC.BookName),价格:\(objBookC.Price)")