Question
(IN JAVA): Within the method, max, in the class Coordinates.java ensure that the return type (new Coordinates object) has an x value which is the
(IN JAVA): Within the method, max, in the class Coordinates.java ensure that the return type (new Coordinates object) has an x value which is the maximum of this point's x and coordinate's x, and a y value which is the maximum of this point's y and coordinate's y. do not change the original Coordinates objects. For example: Coordinate c1 = new Coordinate( 10, 0 );
Coordinate c2 = new Coordinate( 20, -10 );
c1.max( c2 ); // returns a Coordinate at ( 20.0, 0.00 )
Given
----------------------------------------------------------------------
public class Coordinates { private double x; private double y; public Coordinates( double x, double y ) { this.x = x; this.y = y; } public Object max(Coordinates p) { //enter code here } public String toString(){ return String.format("(%.2f, %.2f)", x, y); } }
----------------------------------------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started