Programming Task 2


Time Estimate: 5 hours

Requirements

Project Structure


You will continue to add functionality to your existing project from the previous task. There is no new repository to clone.



Testing Requirements


Note: You can see feedback in Autolab for your tests without completing the programming portion of this task, but you must at least create the classes and methods that you test. You can "stub out" these methods by having them always return a fixed value, but they must exist so the grading code will compile and run.

Write tests in the tests.TestClasses1 class for the following functionality:

  • ratings.Song - In the ratings package, test a class named Song
    • This class will have a constructor that takes 3 parameters in this order:
      1. A String representing the title of the Song
      2. A String representing the artist of the Song
      3. A String representing the Songs ID
    • Song will have getter and setter methods for the three constructor parameters named:
      1. getTitle
      2. setTitle
      3. getArtist
      4. setArtist
      5. getSongID <-- Note that both characters in ID are capital
      6. setSongID
    • For this task, you don't need to implement any additional methods in the Song class (We will add to this class in later tasks)
  • ratings.Rating - In the ratings package, Test a class named Rating
    • This class will have a constructor that takes 2 parameters in this order:
      1. A String representing the ID of the reviewer who gave the rating
      2. An int representing the rating that the reviewer gave
    • Rating will have getter and setter methods for the two constructor parameters named:
      1. getReviewerID
      2. setReviewerID
      3. getRating
      4. setRating
    • Ratings must be in the range 1-5. If someone calls setRatings with an invalid rating, the rating should be set to -1 to indicate that an error has occurred. (eg. setRating(100) should result in the rating being set to -1). This check must also apply when the constructor is called with an invalid rating.
  • ratings.Reviewer - In the ratings package, Test a class named Reviewer
    • This class will have a constructor that takes 1 parameter:
      1. A String representing the ID of the reviewer
    • Reviewer will have getter and setter methods for the constructor parameter named:
      1. getReviewerID
      2. setReviewerID
    • Implement a method named rateSong that takes an int as a parameter and returns a reference to a new Rating object (Using the Rating class described above) with this reviewer's ID and the rating from the parameter of this method.


Programming Requirements


Implement the Song, Rating, and Reviewer classes with all of the functionality you've tested above.



AutoLab Feedback


The feedback in AutoLab will be given in 3 phases. If you don't complete a phase, then feedback for the following phase(s) will not be given.

  1. Running your tests on a Correct Solution
  2. Running your tests on several Incorrect Solutions
  3. Running my tests on Your Solution

Once you complete all 3 phases, you will have completed this Task and AutoLab will confirm this with a score of 1.0 for complete.