Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Song Suppose you want to have an application to keep track of all the songs you have. The first step is to define a class

image text in transcribed

Song Suppose you want to have an application to keep track of all the songs you have. The first step is to define a class that represents a Song and all the information you want to store about it Write your code in the file Song.java to implement a class called Song with the following private attributes (use the exact names). name: a String for the name of the song, year: an integer for the year the song was released numberOfWriters: an integer to store the number ofthe songs composers, writers: an array of Strings to store the name of the song's composers. A song can have a maximum of 50 composers, rating: an integer value ranging from 1 (horrible) to 5 (the best song ever) Your class should also contain the following methods (use the same signature) public Song (String name): that takes as an argument the song's name public void setVame (String name): updates song's name attribute, public String getName 0: returns song's name attribute, public void setlear int year): updates song's year attribute public int getear): returns song's year attribute, public void setRating int rating) update song's rating attribute public int getRating ): returns song's rating attribute, public void addWriter(String wri terVame): receives a String with the writer's name as a parameter and inserts the String into the writer array at the first empty position, update numberOfWriters to reflect the new number of writers, public Stringll getri ters): returns the writers array attribute public int getMmberOfwri ters retuns the value of numberOfWriters attribute public String getKri terAtIndex (int index): returns the writer's name at that index. Use o based indexing where an index of O is the first name t should return null if there is no writer at that index public String toString () returns the string representation of this song with the song's name, year, and rating Output in the format "name, year public boolean equals (Object other): returns true if this object is the same as other object. Two objects are equal if they have the same name rating the same writers/composers, and were released at the same year Assume the ordering of writers might not be the same and no duplicate writer name exists in either song. public int compareTo (Song other): return O if this song's name is lexicographically equal to othersong's name; Return a negative number, say-1, if this song's name is less than the other song's name lexicographically, Return a postive number, say 1, if this song's name is greater than the other song's name lexicographically You may write your own main method to test your class. Autolab will ignore your main method. Note: 3 submissions without deductions, 5 points deduction for every submission thereafter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions