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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter1: Creating Java Programs
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question
100%

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I am having trouble running the code, it says there are a lot of errors and I am not sure I am even running it right. How would I go about running the code and fixing the errors in C++

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT