Created
September 13, 2022 23:25
-
-
Save benlmyers/e5a36d656fada815068419261a655e36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Food.swift | |
// MVVM-SwiftUI | |
// | |
// Created by Ben Myers on 9/13/22. | |
// | |
import Foundation | |
/** | |
An object representing a yummy snack. | |
Primarily displayed in ``FoodView``. | |
*/ | |
struct Food: Codable { | |
// MARK: - Properties | |
/// The name of the food. | |
var name: String | |
/// Whether this is the user's favorite food. | |
var favorite: Bool | |
/// An emoji representing the food item. | |
var emoji: String { | |
if name.contains("apple") { | |
return "๐" | |
} else if name.contains("taco") { | |
return "๐ฎ" | |
} else if name.contains("banana") { | |
return "๐" | |
} else if name.contains("soup") { | |
return "๐" | |
} else { | |
return "๐ด" | |
} | |
} | |
// MARK: - Methods | |
/** | |
Eat the food. | |
*/ | |
func eat() { | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment