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:
class OrderedNotebook: Notebook
Properties
private var orderedKeys: String
Override add method to maintain order
override func addnote: Note
super.addnote: note
if orderedKeys.containsnoteid
orderedKeys.appendnoteid
Override remove method to maintain order
override func removeid: String Note?
if let removedNote super.removeid: id
if let index orderedKeys.firstIndexof: id
orderedKeys.removeat: index
return removedNote
return nil
Method to sort notes
func sortNotesby closure: Note Note Bool
orderedKeys.sort id id in
guard let note selfid let note selfid else return false
return closurenote note
Override to get all notes in order
override func getAllNotesNote
return orderedKeys.compactMap self$
Can you please make whatever additionsmodifications 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. If I've done anything wrong on that end so far, please do correct it as part of the final product you dish out. Thank you.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
