Create two classes.
Song. Should include the name of the song and the artist
Playlist. Should include a list of song objects from the above class, a title for the list and a description of the list. Specific method requirements below.
Functionality
You should be able to print both a song and a playlist. Formatting should follow the below examples EXACTLY. I should be able to print a so11ng or a playlist by calling the standard python print function.
|
Format for printing a song should be |
Format for printing a play list should be |
|
Title: <song title> Example. Title: Bad Guy Artist: Billie Eilish |
Playlist: <playlist title> <title1> <title2> . <titleN> Example. Playlist: Country Gooderns Friends in Low Places Stand by your Man |
The play list class should allow adding songs through an addSong method. Duplicate song names are not allowed and should result in an error message back to the user. Songs with the same title but different case would be considered duplicates. Walk The Line would be considered a duplicate of WALK THE line.
The play list class should allow searching to see if a song exists through a songFound method. This search can be done on an exact match of the title (upper or lower case allowed). If I searched for walk THE Line in the above list, it would find a match. Result should be returned as a Boolean.
The play list class should allow randomizing the order of the songs in the list through a shuffleList method. Songs would normally be included in the order they were added. If I call the randomize process, the playlist should be shuffled into a random order of songs.
I have created all the classes in a single file and included main method to test the methods in classes. Please feel free to change the main method in any way required
Below are the screenshots of the file:



Below is the code for the same:
from random import shuffle
class Song:
def __init__(self, name, artist):
self.name = name
self.artist = artist
# Method to print a Song
def print(self):
print("Title: ", self.name)
print("Artist: ", self.artist)
class Playlist:
def __init__(self, title, desc):
self.title = title
self.desc = desc
self.songs = []
# Method to add a Song
def addSong(self, newSong):
# Checking for duplicate songs even if the case is different
for song in self.songs:
if song.name.upper() == newSong.name.upper():
return "Error: Song with title '" + newSong.name + "' already exists"
# If it is not a duplicate add to the list
self.songs.append(newSong)
return "Successfully added '" + newSong.name + "'"
# Method to search a song
def songFound(self, songTitle):
for song in self.songs:
if song.name.upper() == songTitle.upper():
return True
return False
# Method to shuffle the list of songs to change their order
def shuffleList(self):
shuffle(self.songs)
# Method to print the Playlist
def print(self):
print("Playlist: ", self.title)
print("Description: ", self.desc)
print("Songs:")
for song in self.songs:
print(song.name)
def main():
# Creating Song objects
s1 = Song("Bad Guy", "Billie Eilish")
s2 = Song("Coal Miner's Daughter", "Billie Donald")
s3 = Song("Walk the Line", "Cathy")
s4 = Song("Friends in low places", "John")
# Creating a Playlist
p1 = Playlist("Country Gooderns", "Classic Country Songs")
# Adding songs to the playlist
print(p1.addSong(s1))
print(p1.addSong(s2))
print(p1.addSong(s3))
print(p1.addSong(s4))
# Adding a song which already exists
print(p1.addSong(Song("bad guy", "Bowden")))
# Printing the Playlist
p1.print()
# Finding the song in the Playlist
print(p1.songFound("Bad Guy"))
# Shuffling the songs
p1.shuffleList()
# Printing the sings after shuffling
p1.print()
if __name__ == "__main__":
main()
Below is the screenshot of sample output:

Please feel free to change the output in a way required. Hope this helps you and also hoping for a positive review
Create two classes. Song. Should include the name of the song and the artist Playlist. Should...
Overview: You will be writing classes that implement a playlist simulation for a music streaming app.The Playlist class will contain a dynamic array of Song objects, and the Song class contains several pieces of information about a song. You will need to: 1) Finish the writing of two classes: Song and Playlist. The full header file for the Song class has been provided in a file called Song.h. 2) Write a main program (filename menu.cpp) that creates a single Playlist...
I need c++ code Given the complete main() function, partial playlist class header playlist.h, and playlist.cpp, you will complete the class declaration and class implementation. The following member functions are required: constructor copy constructor destructor addSong(song tune) adds a single node to the front of the linked list no return value displayList() displays the linked list as formatted in the example below no return value overloaded assignment operator A description of all of these functions is available in the textbook's...
(1) Create two files to submit: Song.java - Class definition MainClass.java - Contains main() method (2) Build the Song class in Song.java with the following specifications: Private fields String songTitle String songArtist int secDuration Initialize String fields to "Not defined" and numeric to 0. Create overloaded constructor to allow passing of 1 argument (title), 2 (title, artist) and 3 arguments (title, artist, duration). Create public member method printSongInfo () with output formatted as below: Title: Born in the USA Artist:...
Introduction In this final programming exercise, you'll get a chance to put together many of the techniques used during this semester while incorporating OOP techniques to develop a simple song playlist class. This playlist class allows a user to add, remove and display songs in a playlist. The Base Class, Derived Class and Test Client Unlike the other PAs you completed in zyLabs, for this PA you will be creating THREE Java files in IntelliJ to submit. You will need...
THE ENTIRE CODE SHOULD BE IN JAVA Playlist (output linked list) Given main(), complete the SongNode class to include the printSongInfo() method. Then write the Playlist class' printPlaylist() method to print all songs in the playlist. DO NOT print the dummy head node. Ex: If the input is: Stomp! 380 The Brothers Johnson The Dude 337 Quincy Jones You Don't Own Me 151 Lesley Gore -1 the output is: LIST OF SONGS ------------- Title: Stomp! Length: 380 Artist: The Brothers...
public class Song {
private String title;
private String artist;
private int duration;
public Song() {
this("", "", 0, 0);
}
public Song(String t, String a, int m, int s) {
title = t;
artist = a;
duration = m * 60 + s;
}
public String getTitle() { return title; }
public String getArtist() { return artist; }
public int getDuration() { return duration; }
public int getMinutes() {
return duration / 60;
}
public int getSeconds() {
return...
JAVA PROGRAMMING Given main(), complete the SongNode class to include the printSongInfo() method. Then write the Playlist class' printPlaylist() method to print all songs in the playlist. DO NOT print the dummy head node. Ex: If the input is: Stomp! 380 The Brothers Johnson The Dude 337 Quincy Jones You Don't Own Me 151 Lesley Gore -1 the output is: LIST OF SONGS ------------- Title: Stomp! Length: 380 Artist: The Brothers Johnson Title: The Dude Length: 337 Artist: Quincy Jones...
Question on struct Write a struct called Song. Song will have the data members string title, string artist, int yearRecorded, string genre, int lengthMin, and int lengthSec. This struct will have object-values song1, song2, song3, song4, song5, song6, song7 and song8. Add your code for the struct Song to the following code. Then test that it runs, what exactly is printed when it is run? void printSong(Song); int main() { song1.title = "YYZ"; song1.artist = "Rush"; song1.yearRecorded = 1981; song1.genre...
Ch 8 Program: Playlist (Java)You will be building a linked list. Make sure to keep track of both the head and tail nodes.(1) Create two files to submit.SongEntry.java - Class declarationPlaylist.java - Contains main() methodBuild the SongEntry class per the following specifications. Note: Some methods can initially be method stubs (empty methods), to be completed in later steps.Private fieldsString uniqueID - Initialized to "none" in default constructorstring songName - Initialized to "none" in default constructorstring artistName - Initialized to "none"...
Many of us have large digital music collections that are not
always very well organized. It would be nice to have a program that
would manipulate our music collection based on attributes such as
artist, album title, song title, genre, song length, number times
played, and rating. For this assignment you will write a basic
digital music manager (DMM). Your DMM program must have a
text-based interface which allows the user to select from a main
menu of options including:...