subject

Overriding the equals methodfile player. java contains a class that holds information about an athlete: name, team, and uniform number. file compareplayers. java contains a skeletal program that uses the player class to read in information about two baseball players and determine whether or not they are the same player.1. fill in the missing code in compareplayers so that it reads in two players and prints "same player" if they are the same, "different players" if they are different. use the equals method, which player inherits from the object class, to determine whether two players are the same. are the results what you expect? 2. the problem above is that as defined in the object class, equals does an address comparison. it says that two objects are the same if they live at the same memory location, that is, if the variables that hold references to them are aliases. the two player objects in this program are not aliases, so even if they contain exactly the same information they will be "not equal." to make equals compare the actual information in the object, you can override it with a definition specific to the class. it might make sense to say that two players are "equal" (the same player) if they are on the same team and have the same uniform number. use this strategy to define an equals method for the player class. your method should take a player object and return true if it is equal to the current object, false otherwise. test your compareplayers program using your modified player class. it should give the results you would expect.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
What can a word user do with the customize ribbon dialog box? check all that apply. minimize the ribbon add a new tab to the ribbon remove a group from a tab add a group to a tab choose which styles appear choose which fonts appear choose tools to appear in a group
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
You know the right answer?
Overriding the equals methodfile player. java contains a class that holds information about an athle...
Questions
question
Business, 09.05.2021 16:40
question
Chemistry, 09.05.2021 16:40
question
Chemistry, 09.05.2021 16:40
question
Mathematics, 09.05.2021 16:40
Questions on the website: 13722361