Question: I am looking to create a set of code which meets all of the requirements listed in the picture given below. Here's what I have

I am looking to create a set of code which meets all of the requirements listed in the picture given below. Here's what I have so far:
struct Note {
// Nested Enum for Priority Levels
enum PriorityLvl: Int {
case low =1
case medium
case high
mutating func incrementLvl(){
if self.rawValue PriorityLvl.high.rawValue {
self = PriorityLvl(rawValue: self.rawValue +1)!
}
}
mutating func decrementLvl(){
if self.rawValue > PriorityLvl.low.rawValue {
self = PriorityLvl(rawValue: self.rawValue -1)!
}
}
}
// Properties
let id: String
var priority: PriorityLvl
var body: String
// Initializer
init(id: String = UUID().uuidString, priority: PriorityLvl =.low, body: String = "New Note"){
self.id = id
self.priority = priority
self.body = body
}
// Methods
mutating func updateBody(newBody: String)-> String {
self.body = newBody
return self.body
}
func toString()-> String {
return "\(priority): \(body)"
}
}
Can you please make whatever additions/modifications needed to the code to ensure it meets all requirements laid out in the photo and operates correctly? Just to be clear, this means down to every last detail given in those instructions, as to make sure it all matches up in the end. Thank you.
I am looking to create a set of code which meets

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!