Question 1[2 marks]
Class File: private filename //Constructor for the File class procedure new(strFilename): filename = strFilename public procedure rename(strFilename) if strfilename!="": filename = strFilename Class MP3 inherits File: private title private artist private duration //Constructor for the MP3 class procedure new(strFilename, strTitle, strArtist, intDuration): super.new(strfilename) title = strTitle artist = strArtist duration = strDuration public function getDuration(): min = duration // 60 sec = duration % 60 return (str(min) + ":" + str(sec))
What code would you write to instantiate one new MP3 object called topTrack for the lastest 3 minutes 12 seconds song “Shivers” from Ed Sheeran?
Question 2[4 marks]
What are all the methods and properties of the MP3 class?
Question 3[4 marks]
Explain, using an example from this code, what is meant by inheritance?
Save / Share Answers as a link
Here is your link with your answers. You can save this link or share it with your teacher:
Copy URL to Clipboard
Solution...The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area