protocol Product {
var name: String { get }
var expiredDate: Date { get }
/**
* Function to get all of information about product
*/
func getProductInfo()
}
class Vegetable: Product{
var name: String {
return "Broccoli"
}
var expiredDate: Date {
return Date()
}
func getProductInfo() {
// some magic code
}
}
class Smartphone: Product{
var name: String {
return "Samsung S10+ Limited Edition"
}
var expiredDate: Date {
return Date() // ?????
}
func getProductInfo() {
// some magic code
}
}