Code a generic class called Location that describes a point in the xy plane. The Location class requires instances variables to represent the x and y coordinates, a parameterized constructor, one method to change both coordinates of the point (both x and y), getX and getY methods and a toString. These are the only methods in this class. The class uses a generic type so that any numeric value can be used for the coordinates (2 integers, 2 floats, 2 doubles, etc) or 2 Strings (for example three and ten).
Java:
Code a generic class called Location that describes a point in the xy plane. The Location class requires instances variables to represent the x and y coordinates, a parameterized constructor, one method to change both coordinates of the point (both x and y), getX and getY methods and a toString. These are the only methods in this class. The class uses a generic type so that any numeric value can be used for the coordinates (2 integers, 2 floats, 2 doubles, etc) or 2 Strings (for example three and ten).
Write a code segment in main( ) to thoroughly test the class Location. Your code segment should create two locations, one represented by a pair of real numbers and one represented by a pair of Strings.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images