Highlights
In this task, you will create a program to find and play music stored in an archive on your machine. The words highlighted with bold in the text are either Python keywords or names to be used in the finished program. Test programs have been created for both classes, to be used before you deliver. You may want to extend the test programs with more tests and prints, but those already present should not be removed.
Both classes and test programs must be delivered. Also, picture/scanned figure and a text file with answers to the theory questions in exercise 3. It is important that you comment in Devilry how the solution works and what has been challenging and easy. If the solution doesn't work for every test, describe which tests fail and suggest why.
Exercise 1, Class Sang
You must write a class Sang as a separate module in the sang.py file, with the following interface: The class should have a constructor with parameters tittel and artist (in addition to self). The constructor must create instance variables _tittel and _artist. These are strings that get value from the parameters. The instance variable _artist is a string consisting of one or more letter sequences separated by blank characters. Examples: "Simon and Garfunkel", "The Rolling Stones", "Prince". The class will also offer the following methods in the interface: spill "plays" the music in the song it is called - in this program it means the message "Plays <info about title and artist>" appears on the terminal. sjekkArtist with parameter navn (a string) in the same form as the instance variable _artist. The method returns True if one or more of the names in the string navn exists in artist, otherwise False. sjekkTittel with parameter tittel (a string). The method checks if the specified title is the same as in the instance variable and returns True by equality, otherwise False. The titles should be defined as equal, regardless of upper/lower case letters. sjekkArtistogTittel with parameters artist and tittel. The method returns True if both the title and the artist (the same rules as in the corresponding check methods) agree with the songs instance variables, otherwise False.
Exercise 2 Class Spilleliste
In the spilleliste.py file, you will find the definition of the class Spilleliste. The constructor is finished, while the following methods should be completed by you:
lesFraFil with parameters self and filnavn. The method opens the specified file and loads the data about its songs - one line per song, in the format: title; artist Since both title and artist can contain blank characters, semicolons are used as separators. Also note that you may want to remove a character break at the end of each line. Reading a line can then be done as follows:
alleData = linje.strip (). split ( ';' )
The method should create new Sang objects as the file is read, and add them to the playlist. The file is finally closed. See the Voluntary Extension section below for possible extensions. leggTilSang with parameters self and nySang, where nySang is the new object to be added to playlist. fjernSang with parameters self and sang. spillSang with parameters self and sang. spillAlle with parameter self, which plays each song in the list. finnSang with parameters self and tittel, which looks through the list of songs by one with the specified title and returns the first one it finds. If the title is not found in the playlist, None is returned. hentArtistUtvalg with parameters self and artistnavn . The method goes through all the songs in the playlist and saves those who have one or more names from the artistnavn parameter in the artist name. These are to be returned in a list of songs. In the files sangtester.py and spillelistetester.py there are test programs for the two classes, and the file musikk.txt contains the data for loading into the program. They can be useful in developing the classes, and will be used by the group teacher for assessing your submission.
Problem 3 Theory questions
Answer to Task a) is delivered as a scanned document (possibly a photo taken with your mobile phone) while Task b) and c) answered in a text file.
a) Make a drawing, preferably on paper, of the data structure as it looks after a playlist is read from the musikk.txt file. You do not need to draw more than two Song objects. Use the notation from lectures, with variables such as boxes, objects like circles or boxes with round corners, and references that arrow from a variable to an object. You can drawstrings like content in simple variables (even though they are really objects), while a list is drawn as an object
which is referenced from a list variable.
b) In the class Spilleliste, there is an instance variable that stores all the songs in a list. Mention at least one, preferably two reasons why a dictionary is not suitable in this case.
c) The class Spilleliste could have the filename as a parameter for the constructor and read the playlist from file when creating a new Spilleliste-object. Do you see any benefit in not doing this in constructor?
This English Assignment has been solved by our English experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.