创建模板类(封装一个类)
新建一个名字叫做 Product
的类
Product.swift File
的内容
class Product {
var name: String
var description: String
var price: Double
var stock: Int
init(name: String, description: String, price: Double, stock: Int) {
self.name = name
self.description = description
self.price = price
self.stock = stock
}
}
时间: 2024-10-11 01:25:41