In this week's lab you will learn about:
ArrayLists
Comparing Objects
Using "==" to compare two objects only compares their memory address; i.e., it checks if they're the same object, not if they have the same value.
For this reason, most objects define an "equals" method that can be used to compare one instance of an object to another based on the value of the instance variable(s).
Today we will create a class that represents CDs, and write an equals method for the class so you can compare them.
Develop a class, CD, with the following attributes:
title
artist
releaseDate
recordLabel
Write accessors and mutators for the variables, a default constructor, and a constructor that accepts values for all variables.
Write an equals method for CD that works like String's equal method; that is, it accepts another CD as an argument, compares the two CDs ("this" CD and the parameter) based on the value of their instance variables, and returns a boolean indicating if their data is equal.
Create a driver to test your class. Don't worry about realistic interaction with the user, just create CDs with hard-coded values and verify that CDs with all the same values return "true" when compared with the equals method and CDs with 1 or more different values return "false".