141k views
4 votes
Write a program in C++ language that implements a music player using Doubly Circular Linked List using OOP concepts. This assignment has four parts: 1- Write a class(new type) to define the Song type. 2- Implement the Doubly Circular Linked List, which will operate with Song type. 3- Implement the Music Player 4- Test it in the main function All Constructors should use the initializer list. 1. Song class Member variables: - string songTitle;//song title - string singerName;//singer name Member functions: - Song(string, string); - virtual Song(); - string getSongTitle(); - string getSingerName(); - void setSongTitle(string); - void setSingerName(string); - Overload ≪ operator, this will help to print an object of type Song. Answer questions below before implementing class Song: Which methods should be public and which ones can be private? Should data members be public or private? 2. Implement the Doubly Circular Linked List (you need to implement two classes, one for node and one for operations on Doubly Circular Linked List), this implementation should support the MusicPlayer Class. Member variables: - string type; //will hold the type of the music player - int size; //the current number of the songs - CircleDLinkedList playerList; // list of the songs, CircleDLinkedList is the Doubly Circular Linked List Member functions: - MusicPlayer(string); - virtual MusicPlayer(); - play(); //plays the current song, meaning that this method will print the properties of the Song - next();// moves to the net song and plays it - previous(); ////moves to the previous song and plays it - add (Song); //adds a song before the current song - remove(); //removes the current song - print(bool);//prints all songs that are in the list, starting from current to left is bool param is true and reverse order is bool parameter is false (this function should be designed as a recursive function) Answer questions below before implementing class MusicPlayer: Which methods should be public and which ones can be private? Should data members be public or private? Should we create getters and setters methods for member variables? For which member makes sense to implement them? 4. Test it in the main function Create e musicplayer with 3 songs. Play the current song. Play the next song. Play the next song. Play the next song. Test it in the main function Create e musicplayer with 3 songs. Play the current song. Play the next song. Play the next song. Play the next song. Play the previous song. Print the list of the songs using bool parameter true. Print the list of the songs using bool parameter false. Remove the current song from the musicplayer. Play the current song. Play the next song. Play the next song. Play the next song. Print the list of the songs using bool parameter true. Print the list of the songs using bool parameter false.

1 Answer

1 vote

Final answer:

The Song class needs private data members and public methods, while the MusicPlayer should also maintain private data members and provide public methods for functionality. Test in the main function involves creating a MusicPlayer, adding songs, and testing its methods.

Step-by-step explanation:

The Song class should be designed with private member variables to encapsulate its data, ensuring data integrity and providing control over the values. Public methods should be provided for external interaction with these members, such as getters and setters, and to facilitate specific functionality like displaying the song details. The constructor should be public for creating Song objects.

The MusicPlayer class would also hold private data members to maintain the encapsulation principle of OOP. Public methods should include those that allow interaction with the music player, such as play, next, previous, add, remove, and print. Getters and setters can be provided for member variables where external access or modification is necessary, but careful consideration should be given to whether allowing such access is appropriate for each specific member.

When writing the test in the main function, it involves creating an instance of MusicPlayer, adding songs to it, and testing the functionality of various methods such as play, next, previous, add, remove, and print, as per the requirements stated in the assignment.

User Mohammed Faour
by
7.0k points