Question: Exercise 3 Create the Song class which represents a song on a streaming service. The class should have the following attributes: artist - string representing
Exercise
Create the Song class which represents a song on a streaming service. The class should have the following attributes:
artist string representing who sings the song
title string representing the name of the song
album string representing the album on which the song appears
playCount integer representing how many times the song has been played
payRate a constant double that represents how much money the artist receives each time a song is played
moneyEarned a double representing how much money the song has earned the artist
All attributes should have a getter method, and all attributes except for payRate and moneyEarned should have a setter method. Use the Java convention for naming the getters and setters. Users should be able to call the play method which updates the playCount and moneyEarned attributes.
Expected Output
Instantiate a Song object and play the song one time. Print the money earned. Then play it another tExercise
Create the Song class which represents a song on a streaming service. The class should have the following attributes:
artist string representing who sings the song
title string representing the name of the song
album string representing the album on which the song appears
playCount integer representing how many times the song has been played
payRate a constant double that represents how much money the artist receives each time a song is played
moneyEarned a double representing how much money the song has earned the artist
All attributes should have a getter method, and all attributes except for payRate and moneyEarned should have a setter method. Use the Java convention for naming the getters and setters. Users should be able to call the play method which updates the playCount and moneyEarned attributes.
Expected Output
Instantiate a Song object and play the song one time. Print the money earned. Then play it another times and print how much the song has earned. Note, the moneyEarned attribute only updates when the play method is called. Using the setPlayCount method will update playCount but it will not update moneyEarned. That is why the for loop is used.
add code below this line Song mySong new Songled zeppelin", "ten years gone", "physical graffiti", ; mySong.play; System.out.printlnmySonggetMoneyEarned; for int i ; i ; i mySong.play; System.out.printlnmySonggetMoneyEarned; add code above this line
Your program should produce the following output:
Important
The payRate and moneyEarned attributes should not have a setter method. The values for moneyEarned and playCount should start with when a Song object is instantiated.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
