Letβs write the struct definition for Song. Song should have instance variables title, artist, and numLikes (in that order). Put the necessary blocks of code in the correct order.
Letβs make an album! Write the struct definition for Album, which should have instance variables name, year and a vector of Songs (in that order). Put the necessary blocks of code in the correct order.
Two Songs are equal if the title and artist of the Songs are equal. Write the function songEqual, which takes two Songs as parameters and returns true if they are equal. Put the necessary blocks of code in the correct order.
What if weβd like to search an album for our favorite song? Write the Album member function searchAlbum which takes a Song as a parameter and returns the location of the Song in the album. If the song isnβt found, return -1. Use the songEqual function we defined earlier! Put the necessary blocks of code in the correct order.
int Album::searchAlbum(const Song& a) {
---
int searchAlbum(const Album& album, const Song& a) { #distractor
---
bool searchAlbum(Song const &a) { #distractor
---
for (size_t i = 0; i < songs.size(); ++i) {
---
for (size_t i = 0; i < album.size(); ++i) { #distractor
---
for (size_t i = 0; i < Song.size(); ++i) { #distractor
---
if (songEqual (songs[i], a)) {
---
if (songs[i] == a) { #distractor
---
if (album.song == a) { #distractor
---
if (Song[i] == a) { #distractor
---
return i;
---
return true; #distractor
---
}
---
}
---
return -1;
---
return false; #distractor
---
}
Whatβs the most popular Song within an Album? Letβs write the Album member function mostLikedSong, which prints out the information of the most liked Song in the format βThe most liked song is title by artist with numLikes likes.β Put the necessary blocks of code in the correct order.
Letβs write the struct definition for Product. Product should have instance variables name and price. Put the necessary blocks of code in the correct order.
Letβs make a shopping list! Write the struct definition for List, which should have instance variables type and a vector of Products. Put the necessary blocks of code in the correct order.
Two Products are equal if the name and price of the Products are equal. Write the function productEqual, which takes two Products as parameters and returns true if they are equal. What if we want to check to see if we have bananas in our shopping list? Write the List member function searchList, which takes a Product as a parameter and returns the location of the Product in the List. Return -1 if itβs not in the List. Put the necessary blocks of code in the correct order.
Time to checkout! Write the List member function totalPrice which calculates and returns the total price of all the Products. Put the necessary blocks of code in the correct order.
Oops! We made a mistake and grabbed pineapple pizza. What if we want to remove an Product from our List? Write the List member function removeProduct, which takes an index as a parameter and removes it. Then it fills the gap with the last product in the List. Put the necessary blocks of code in the correct order.