A07
Due Date:
Friday, November 3
File(s) to be submitted:
MusicTrack.java
Sample Output:
SampleOutput.html
Starter Files:
SUBMIT
/
Check
MusicTrack
(objects with constructors, getters, and setters)
Summary
We
are creating a non-program class this week. The MusicTrack class keeps track of
the list of music tracks, as the name suggests!
I
have provided a tester program. Do not change the tester program except by
deleting the lines labeled DELETE THIS LINE when .... If you change the program
code, then your MusicTrack class code probably won't work the way we want it
to.
Exception:
You are allowed to change the package name
or delete the package a07; command completely.
The
tester program tests the MusicTrack class bit by bit. You should make sure that
each bit is completely correct before you move on to the next bit. Create the
methods in the order TestMusicTrack uses.
Note for those with computer programming experience.
We know
that having the constructors and setters print error messages is not best practice.
But we want you to do it anyway.
We are not going to cover throwing and catching exceptions
until next term (CSCI 1228),
so we can't expect beginners to know how to do that.
So if you do throw exceptions,
our testing programs won't work,
and you will get a bad grade.
Also,
we want you to print the error messages to System.out
instead of System.err.
For similar reasons.
Details
MusicTrack
objects have four instance variables, namely artist, title, length and
downloadCount.
-
The instance variable artist holds the name of the artist.
-
The instance variable title holds the name of the music track.
-
The instance variable length represents the length of the track in minutes
(e.g., a 3 minutes and 30 seconds track has a length of 3.5)
-
The instance variable downloadCount represents the number of times this music
track has been downloaded.
This class
also has the following public methods:
-
MusicTrack: This is the constructor in which you need to initialize all the
instance variables. Make sure the corresponding parameters for length and
downloadCount are positive numbers; otherwise set them to 0 and print a warning
message as shown in the sample output.
-
Getters for all instance variables: getArtist, getTitle, getLength and
getDownloadCount.
-
Setters for all instance veriables: setArtist, setTitle, setLength,
setDownloadCount. Again, make sure the corresponding parameters for length and
downloadCount are positive numbers; otherwise print a warning message as shown
in the sample output.
Grading Outline
-
12 points: The program has 4 instance variables defined properly from
appropriate data types.
-
10 points: The constructor has been implemented properly to initialize all
instance variables.
-
8 points: The constructor produces appropriate error message for invalid
parameters and set the corresponding instance variables to the correct
value.
-
5 points: The method getArtist works as expected.
-
5 points: The method getTitle works as expected.
-
5 points: The method getLength works as expected.
-
5 points: The method getDownloadCount works as expected.
-
5 points: The method setArtist has been implemented properly.
-
5 points: The method setTitle has been implemented properly.
-
10 points: The method setLength has been implemented properly (5 points) and
functions correctly in case of invalid parameters (5 points).
-
10 points: The method setDownloadCount has been implemented properly (5 points)
and functions correctly in case of invalid parameters (5 points).
-
5 points: The opening Javadoc has been provided properly.
-
10 points: All methods have proper javadocs.
-
5 points: All style rules are followed including appropriate indentation,
commenting and variable names.
SUBMIT
/
Check