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, 24.06.2019 00:30
Match the sentence fragment in the first column with the appropriate ending in the second column. a little per favore?
Answers: 1
question
Computers and Technology, 24.06.2019 10:50
In 2009 to 2010, how many social network users were reported as being victims of online abuse? a. 1 in 10 b. 100% c.1 in 100 d. 50%
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. the program should output the average high, average low, and the highest and lowest temper- atures for the year. your program must consist of the following functions: a. function getdata: this function reads and stores data in the two- dimensional array. b. function averagehigh: this function calculates and returns the average high temperature for the year. c. function averagelow: this function calculates and returns the aver- age low temperature for the year. d. function indexhightemp: this function returns the index of the highest high temperature in the array. e. function indexlowtemp: this function retur
Answers: 3
question
Computers and Technology, 24.06.2019 18:00
Explain the circumstances for which the interquartile range is the preferred measure of dispersion. what is an advantage that the standard deviation has over the interquartile range? choose the correct answer below. a. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it increases as the dispersion of the data increases. b. the interquartile range is preferred when the data are not skewed or no have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. c. the interquartile range is preferred when the distribution is symmetric. an advantage of the standard deviation is that it is resistant to extreme values. d. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it is resistant to extreme values. e. the interquartile range is preferred when the data are skewed or have outliers. an advantage of the standard deviation is that it uses all the observations in its computation. f. the interquartile range is preferred when the data are bell shaped. an advantage of the standard deviation is that it increases as the dispersion of the data increases.
Answers: 2
You know the right answer?
Overriding the equals methodfile player. java contains a class that holds information about an athle...
Questions
question
Mathematics, 22.09.2019 06:30
question
World Languages, 22.09.2019 06:30
question
Mathematics, 22.09.2019 06:30
question
Mathematics, 22.09.2019 06:30
question
Biology, 22.09.2019 06:30
question
Mathematics, 22.09.2019 06:30