Question: The sales program found below is currently missing three desired pieces of functionality---it doesn't store record sales, nor is it able to print the top

  1. The sales program found below is currently missing three desired pieces of functionality---it doesn't store record sales, nor is it able to print the top most expensive sales. Provided for you is the RecordSale class which contains the album title and sale price for a particular record, and the SalesHistory class which is responsible for maintaining the list of past sales. 

  2. Your task is to implement this missing functionality by defining two additional methods in the SalesHistory class: a) add_sale, and b) print_top_sales. 

  3. a) Defining the add_sale method This method takes an album title and its sale price as arguments instantiates a new RecordSale object, and then appends it to the sales instance variable (which is a list). 

  4. b) Defining the print_top_sales method This method takes no arguments and prints the album title and sale price of the top three most expensive sales in descending order of price (i.e. highest to lowest). Each line in the output should be numbered (see example run). In order to sort the auction sale items you should use the sort list method (documented here). You will need to make use of the sort method's two named arguments when calling it.

Step by Step Solution

3.32 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the modified SalesHistory class with the missing functionality python class RecordSale def ini... View full answer

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!