How should you complete the relevant code segment?

DRAG DROP
You are developing a class named Temperature.
You need to ensure that collections of Temperature objects are sortable.
How should you complete the relevant code segment? (To answer, drag the appropriate
code segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)

DRAG DROP
You are developing a class named Temperature.
You need to ensure that collections of Temperature objects are sortable.
How should you complete the relevant code segment? (To answer, drag the appropriate
code segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)

Answer:



Leave a Reply 4

Your email address will not be published. Required fields are marked *


BramscoChill

BramscoChill

it doesn’t matter if you swith those two:
return this.Fahrenheit.CompareTo(otherTemperature.Fahrenheit);
return otherTemperature.Fahrenheit.CompareTo(this.Fahrenheit);

kasp

kasp

wrong: if one of the two returns 1 then the other will return -1, but we need to be consistent with the logic if (obj == null) return 1;

Correct is: 1, 3, 5