Contract
Create a single contract calledFavoriteRecords. It should not inherit from any other contracts. It should have the following properties:
State Variables
The contract should have the following state variables. It is up to you to decide if any supporting variables are useful.- A public mapping
approvedRecords, which returnstrueif an album name has been added as described below, andfalseif it has not - A mapping called
userFavoritesthat indexes user addresses to a mapping ofstringrecord names which returnstrueorfalse, depending if the user has marked that album as a favorite
Loading Approved Albums
Using the method of your choice, loadapprovedRecords with the following:
- Thriller
- Back in Black
- The Bodyguard
- The Dark Side of the Moon
- Their Greatest Hits (1971-1975)
- Hotel California
- Come On Over
- Rumours
- Saturday Night Fever
Get Approved Records
Add a function calledgetApprovedRecords. This function should return a list of all of the names currently indexed in approvedRecords.
Add Record to Favorites
Create a function calledaddRecord that accepts an album name as a parameter. If the album is on the approved list, add it to the list under the address of the sender. Otherwise, reject it with a custom error of NotApproved with the submitted name as an argument.
Users’ Lists
Write a function calledgetUserFavorites that retrieves the list of favorites for a provided address memory.
Reset My Favorites
Add a function calledresetUserFavorites that resets userFavorites for the sender.