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
If joey was single and his taxable income was $9,500, how much would he pay in taxes each year?
Answers: 1
question
Computers and Technology, 25.06.2019 00:40
Roger ginde is developing a program in supply chain management certification for managers. ginde has listed a number of activities that must be completed before a training program of this nature could be conducted. the activities, immediate predecessors, and times appear in the accompanying table: activity immediate predecessor(s) time (days) a -− 44b -− 55 c -− 11 d b 1010 e a, d 55 f c 55 g e, f 1010 calculate the slack time. show the details.
Answers: 2
question
Computers and Technology, 25.06.2019 16:30
How many times do you usually use npm? put your answer in the box.
Answers: 1
question
Computers and Technology, 25.06.2019 19:40
During the installation of ad rms during this lab, you installed ad rms with windows internal database (wid). however, your manager asks why you did not produce the same environment that would be used in production, including using a dedicated sql server. she wants to know the advantages a dedicated sql server provides when backing up and restoring ad rms and how this backup affects the actual documents that are protected with ad rms.
Answers: 1
You know the right answer?
Overriding the equals methodfile player. java contains a class that holds information about an athle...
Questions
question
Mathematics, 09.06.2020 09:57
question
Chemistry, 09.06.2020 09:57
question
Mathematics, 09.06.2020 09:57
question
Mathematics, 09.06.2020 09:57
question
English, 09.06.2020 09:57
question
Mathematics, 09.06.2020 09:57
Questions on the website: 13722367