protocol Product {
var name: String { get }
/**
* Function to get all of information about product
*/
func getProductInfo()
}
protocol FoodProduct: Product {
var expiredDate: Date { get }
}
class Vegetable: FoodProduct{
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"
}
func getProductInfo() {
// some magic code
}
}