Thread: Need help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0

    Need help


    hello

    I need help for my project it is about

    You * will * write * a * PlayList * class * that * manages * a * play * list * of * songs. * The * PlayList * class * manages *a *dynamically *allocated *list *of *song *objects. *The *song *class *is *provided *for *you * in * song.h * and * song.cpp, * which * should * NOT * be * modified. * Your * playlist * class * will * be * implemented * in * two * files * playlist.h * and * playlist.cpp. * The * class * will * support * two * basic * functions: *
    1. Managing *the *playlist. *This *includes *adding *and *deleting *songs. * 2. Playing *from *the *play *list. *This includes keeping track of which is the next song to
    be played. Obviously we will not actually be playing any music. ␣Playing␣ the
    song will consist of printing the name. To support these functions, your PlayList class should have the following public member functions:
    ␣ The class should have a default constructor that builds an empty playlist. ␣ void AddSong(const Song &s);
    This function will add s to the end of the play list. This function should not affect
    the current song index (for playing songs).
    ␣ bool DeleteSong(const Song &s); This function tries to delete s from the play list. If s is in the list, the function deletes the song from the list and returns true. Otherwise, nothing is done and the function returns false. If the play list has multiple copies of one song, you should just delete one copy. If after a song is deleted, the playlist object becomes empty, the function must make the object identical to the one created by a default constructor. This function should reset the current song index only if the index is out of bound after a song is deleted.
    ␣ void ShowAll() const; This function will print all of the songs in the play list on the screen.
    ␣ void play(int num=1); ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣The songs in the list should be play in a circular manner: when reaching the end of the list, repeat from the beginning.
    ␣ void ShowStatus() const; This function shows the status information of the playlist including the number of songs in the list, and the current song index.
    ␣ The class should have a destructor that deletes the memory allocated for the playlist when the PlayList object is deallocated.
    The PlayList class must also overload the following operators and implement the described functionality accordingly:
    1.
    2.
    Addition operator (+): adding a song to a playlist (i.e. playlist object + song object) This routine will return a new playlist object. The returned playlist will be a concatenation of all songs in the caller␣s playlist and the single song at the end (same as the result of AddSong).
    Subtraction operator (-): removing a song from a playlist (i.e. playlist object ␣ song object).This function will return a new playlist object that has the same content as the result of DeleteSong.
    All data members in this class should be private. To support the public and friend functions, the PlayList must maintain a number of data members. The most important one is the playlist that stores an array of songs. However, since there is no size limit on the play list, it must be declared as a Song pointer (e.g. Song *plist;).
    The class must also contain other private member for bookkeeping with at least two private data members: an int member to record the number of songs in the list, and an int member to record the current song index (to support the play function). These members are displayed in the ShowStatus function.
    Test *Program *
    A test program menu.cpp is provided. This program will allow you to interactively test the features of your PlayList class. Keep in mind that this program does not test everything that your class must handle. For example, it doesn't test the operator overloads. To compile the program: put all files in one director␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣ ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0
    // sample main.cpp

    #include <iostream>
    #include "proj5_playlist.h"

    using namespace std;

    void DoAdd(PlayList& play_list)
    {
    Song s;
    cout << "Enter song\n: ";
    cin >> s;

    play_list.AddSong(s);
    }

    void DoDelete(PlayList& play_list)
    {
    Song del_song;
    cout << "Enter song to delete\n: ";
    cin >> del_song;

    if(play_list.DeleteSong(del_song))
    {
    cout << "Song successfully deleted\n";
    }
    else
    {
    cout << "No such song exists\n";
    }
    }

    bool Menu(PlayList& play_list)
    {
    bool good;

    do
    {
    good = true;

    cout << "\n\nPlayList Program!\n"
    << "\tA - Add a song\n"
    << "\tD - Delete a song\n"
    << "\tP - Play a song\n"
    << "\tS - Show all songs\n"
    << "\tT - Show playlist status\n"
    << "\tQ - Quit\n: ";

    char choice;
    cin >> choice;

    switch(toupper(choice))
    {
    case 'A':
    DoAdd(play_list);
    break;

    case 'D':
    DoDelete(play_list);
    break;

    case 'P':
    play_list.Play( );
    break;

    case 'S':
    play_list.ShowAll( );
    break;
    case 'T':
    play_list.ShowStatus();
    break;
    case 'Q':
    return false;

    default:
    good = false;
    }
    } while(!good);

    return true;
    }

    int main( )
    {
    PlayList play_list;

    while(Menu(play_list))
    ;

    return 0;
    }
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0
    // song.cpp

    #include <iostream>
    #include "song.h"
    #include <cstring>
    using namespace std;

    // ignore any newlines in input
    void IgnoreNewLines( )
    {
    while(cin.peek( ) == '\n')
    cin.ignore( );
    }

    // default constructor
    Song::Song( )
    {
    strcpy(title, "");
    strcpy(artist, "");
    }

    Song::Song(const char* t, const char* a)
    {
    Set(t, a);
    }

    void Song::Set(const char* t, const char* a)
    {
    if(strlen(t) < MAX_CHARS)
    strcpy(title, t);

    if(strlen(a) < MAX_CHARS)
    strcpy(artist, a);
    }

    // output operator
    ostream& operator<<(ostream& os, const Song& song)
    {
    os << song.title << ", " << song.artist;

    return os;
    }

    // input operator
    istream& operator>>(istream& is, Song& song)
    {
    // ignore any newlines
    IgnoreNewLines( );

    // read until the comma
    cin.getline(song.title, Song::MAX_CHARS, ',');

    // ignore the space in between
    if(cin.peek( ) == ' ')
    cin.ignore( );

    // ignore any newlines
    IgnoreNewLines( );

    // read until new line
    cin.getline(song.artist, Song::MAX_CHARS);

    return is;
    }

    // equality test operator
    bool operator==(const Song& lhs, const Song& rhs)
    {
    if(strcmp(lhs.title, rhs.title))
    return false;

    if(strcmp(lhs.artist, rhs.artist))
    return false;

    return true;
    }
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0
    // song.h

    #ifndef SONG_H
    #define SONG_H

    #include <iostream>

    using namespace std;

    // Song is a simple class that stores a title and artist as strings
    // it just provides i/o operators, == operator, constructors and Set function
    class Song
    {
    // output the song in the format:
    // title, artist
    friend ostream& operator<<(ostream& os, const Song& song);

    // input the song in the format:
    // title, artist
    friend istream& operator>>(istream& is, Song& song);

    // compare two song objects for equality
    friend bool operator==(const Song& lhs, const Song& rhs);

    public:
    // constructors
    Song( );
    Song(const char* t, const char* a);

    // set the song
    void Set(const char* t, const char* a);

    private:
    static const int MAX_CHARS = 64;

    char title[MAX_CHARS];
    char artist[MAX_CHARS];
    };

    #endif
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,158
    Rep Power
    2222
    Use code tags to preserve your code's indentation. Not doing so makes it unreadable.

    If you have a problem, then you should have questions. Do you have a question?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0
    thank you so much

    I can not do this code

    can any one help me please?
  12. #7
  13. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,158
    Rep Power
    2222
    That is not a question.

    We are ready and willing to help you with any problems you encounter with your work. We respond to questions. We want to help you learn. Doing your homework for you will not help you.

    After having made an honest effort, do you have a question?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0
    i just want a complete code
  16. #9
  17. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,158
    Rep Power
    2222
    Then create it!
  18. #10
  19. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,384
    Rep Power
    1871
    So have you actually done anything at all (ever?).

    Because looking at Lecture 10 , all you seem to have done is copy/paste the example code.

    If you got this far by skipping classes and getting other people to do your homework (which seems likely given how helpless you seem to be, even with plenty of code to crib from), you should just confess and drop the course. You're just way too far behind to ever catch up this year.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  20. #11
  21. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1803
    We can't read your question - look at it! it is junk - what's with all those extra characters? Oh, wait... of course, it is so your tutor cannot search the web for posts of his assignments. Well maybe we could help him by cleaning up the post for you - the following fragment should be enough:
    You will write a PlayList class that manages a play list of songs. The PlayList class manages a dynamically allocated list of song objects. The song class is provided for you in song.h and song.cpp, which should NOT be modified. Your playlist class will be implemented in two files playlist.h and playlist.cpp. The class will support two basic functions:

    1. Managing the playlist. This includes adding and deleting songs.
    I'm not even about to start trying to read it, so I won't be able to answer. If you want volunteers to help, you have to make it easy, and you have to show some effort and interest.

    We can't read your code either and dumping that much unformatted code on a forum and demanding and expecting help is astonishing.
    Last edited by clifford; December 16th, 2013 at 02:55 PM.
  22. #12
  23. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1803
    Originally Posted by nada112
    i just want a complete code
    And your tutor wants your complete code, not ours. Carry on.
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    7
    Rep Power
    0
    all what i post it
    it is from instructor not copt past

IMN logo majestic logo threadwatch logo seochat tools logo