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, 22.06.2019 11:30
What do character formats do for your document's message? a.set the tone b.provide organization c.provide clarity d.set how texts align with documents
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
Given a link with a maximum transmission rate of 32.8 mbps. only two computers, x and y, wish to transmit starting at time t = 0 seconds. computer x sends filex (4 mib) and computer y sends filey (244 kib), both starting at time t = 0. statistical multiplexing is used, with details as follows packet payload size = 1000 bytes packet header size = 24 bytes (overhead) ignore processing and queueing delays assume partial packets (packets consisting of less than 1000 bytes of data) are padded so that they are the same size as full packets. assume continuous alternating-packet transmission. computer x gets the transmission medium first. at what time (t = ? ) would filey finish transmitting? give answer in milliseconds, without units, and round to one decimal places (e.g. for an answer of 0.013777 seconds you would enter "13.8" without the quotes)
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
Monica and her team have implemented is successfully in an organization. what factor leads to successful is implementation? good between different departments in an organization leads to successful is implementation.
Answers: 1
question
Computers and Technology, 23.06.2019 21:40
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
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, 07.07.2019 07:00
question
Mathematics, 07.07.2019 07:00
Questions on the website: 13722363