Can you help me write a program for this please: Create a class of songs. The class should be called Song and each object in this class represents a song. (This class could be used, for example, in a music library.) Each song has a title, an artist and a recording year. The title and artist are strings and both can consist of multiple words. The year is an integer. Your class should be designed by using the principle of encapsulation. In other words, the data should be private. Create the following operations for this class of objects: (a) A function print(s, out) that prints song s to output stream out in the following format: Title Artist Year 1 Three complete lines are printed. The stream argument has cout as a default value. (b) A function read(s, in) that reads song s from input stream in. The data in the stream is assumed to be in the format specified for print. In particular, three complete lines are read. No errorchecking is performed. The stream argument has cin as a default value. (c) A function equals(s1, s2) that returns true if the songs s1 and s2 have the same title, artist and recording year. (The return value should be a Boolean value, not a string.) Note that these functions should be standalone functions, not methods or member functions. The above describes the arguments of the various functions but not how these arguments are passed to the functions. Part of what you have to do is decide how these arguments should be passed. Make sure to think about it carefully taking into account the discussion we had in class. Consult the notes. Write (and submit) a test driver for your class and its operations. Make sure you test all three functions. 2. Modify the class Song you created for the previous exercise by doing the following: (a) Replace the function print(s, out) by a method print(out) that prints the song to output stream out in the same format as before: 2 Title Artist Year Three complete lines are printed. The argument has cout as a default value. (b) Replace the function read(s, in) by a method read(in) that reads the song from input stream in. The data in the stream is assumed to be in the format specified for print. In particular, three complete lines are read. The argument has cin as a default value. No error-checking is performed. Write (and submit) a test driver for your class 1. If you haven’t used strings in C++ before, you’ll need to include the string library when you test your functions (in addition to iostream). 2. In the implementation of the read function, you’ll want to use the getline function to read the title and artist of the song. In case you’re not familiar with it, getline(in, s) reads characters from input stream in into string s. Characters are read until then end of the current line. The newline character is read but not included in s. 3. In general, functions should do all that they’re supposed to do and nothing else. That’s because some extras, even if well-meaning, might not make sense in every context in which the function could be used. For example, 3 the read function should not prompt the user by printing something like this: Please enter the title of the song: If the function is used to read from cin, that might be OK. But if the function is used to read from a file, that would a bad idea. 4. To test the function equals, you’ll probably want to read two songs and compare them. For example, when the program is ready to read the songs, you might type the following: Moment’s Notice\n John Coltrane\n 1958\n Open Eye Signal\n Jon Hopkins\n 2013\n

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Can you help me write a program for this please:

Create a class of songs. The class should be called Song and each
object in this class represents a song. (This class could be used, for example, in a music library.) Each song has a title, an artist and a recording
year. The title and artist are strings and both can consist of multiple words.
The year is an integer.
Your class should be designed by using the principle of encapsulation. In
other words, the data should be private.
Create the following operations for this class of objects:
(a) A function print(s, out) that prints song s to output stream out
in the following format:
Title
Artist
Year
1
Three complete lines are printed. The stream argument has cout as
a default value.
(b) A function read(s, in) that reads song s from input stream in.
The data in the stream is assumed to be in the format specified
for print. In particular, three complete lines are read. No errorchecking is performed. The stream argument has cin as a default
value.
(c) A function equals(s1, s2) that returns true if the songs s1 and
s2 have the same title, artist and recording year. (The return value
should be a Boolean value, not a string.)
Note that these functions should be standalone functions, not methods or
member functions.
The above describes the arguments of the various functions but not how
these arguments are passed to the functions. Part of what you have to do is
decide how these arguments should be passed. Make sure to think about
it carefully taking into account the discussion we had in class. Consult the
notes.
Write (and submit) a test driver for your class and its operations. Make
sure you test all three functions.
2. Modify the class Song you created for the previous exercise by
doing the following:
(a) Replace the function print(s, out) by a method print(out)
that prints the song to output stream out in the same format as before:
2
Title
Artist
Year
Three complete lines are printed. The argument has cout as a default value.
(b) Replace the function read(s, in) by a method read(in) that
reads the song from input stream in. The data in the stream is assumed to be in the format specified for print. In particular, three
complete lines are read. The argument has cin as a default value.
No error-checking is performed.
Write (and submit) a test driver for your class

1. If you haven’t used strings in C++ before, you’ll need to include the
string library when you test your functions (in addition to iostream).
2. In the implementation of the read function, you’ll want to use the
getline function to read the title and artist of the song. In case you’re not
familiar with it, getline(in, s) reads characters from input stream
in into string s. Characters are read until then end of the current line.
The newline character is read but not included in s.
3. In general, functions should do all that they’re supposed to do and nothing
else. That’s because some extras, even if well-meaning, might not make
sense in every context in which the function could be used. For example,
3
the read function should not prompt the user by printing something like
this:
Please enter the title of the song:
If the function is used to read from cin, that might be OK. But if the
function is used to read from a file, that would a bad idea.
4. To test the function equals, you’ll probably want to read two songs and
compare them. For example, when the program is ready to read the songs,
you might type the following:
Moment’s Notice\n
John Coltrane\n
1958\n
Open Eye Signal\n
Jon Hopkins\n
2013\n 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY