Question: / * * This class represents pairs of integers. * / public class Pair { private int x; private int y; public Pair ( )

/**
This class represents pairs of integers.
*/
public class Pair
{
private int x;
private int y;
public Pair()// default constructor
{
this.x =0;
this.y =0;
}
/**
Create a Pair object with the given values.
@param x x-value for the new Pair object
@param y y-value for the new Pair object
*/
public Pair(int x, int y)
{
x = this.x;
y = this.y;
}
/**
Create a Pair object with the given value
as both its x and y values.
@param v value for both numbers in the new Pair object
*/
public Pair(int v)
{
v = this.x;
}
/**
Create a Pair object with the same values
as the given Pair object.
@param p Pair object whose values should be copied
*/
public Pair(Pair p)
{
p = this. x;
}
/**
Get the x-value of this Pair object.
@return this Pair's x-value
*/
public int getX()
{
return getX;
}
/**
Change this Pair object to have the given x-value.
@param x new x-value for this Pair object
*/
public void setX(int x)
{
this.setX = x;
}
/**
Change this Pair object to have the same x-value
as the given Pair.
@param p Pair object whose x-value should be copied
*/
public void setX(Pair p)
{
// implementation
}
/**
Get the y-value of this Pair object.
@return this Pair's y-value
*/
public int getY()
{
// implementation
}
/**
Change this Pair object to have the given y-value.
@param y new y-value for this Pair object
*/
public void setY(int y)
{
// implementation
}
/**
Change this Pair object to have the same y-value
as the given Pair.
@param p Pair object whose y-value should be copied
*/
public void setY(Pair p)
{
// implementation
}
/**
Change this Pair object to have the same x-value
and y-value as the given Pair.
@param p Pair object whose x-value and y-value should be copied
*/
public void set(Pair p)
{
// implementation
}
/**
Create a new Pair object that contains the swapped x-value
and y-value from this Pair object.
@return a new Pair that has the swapped values from this Pair
*/
public Pair swap()
{
// implementation
}
/**
Determine if this Pair object has the same x-value
and the same y-value as the given Pair.
@param p a reference to a second Pair object
@return true if the given Pair is equal to this Pair
*/
public boolean equals(Pair p)
{
// implementation
}
/**
Determine if the two numbers in this Pair object are the
same two numbers that are in the given Pair without
regard for the order of the numbers. So (2,3) and (3,2)
would have "equal numbers".
@param p a reference to a second Pair object
@return true if this Pair and the other Pair contain the same two numbers
*/
public boolean equalNumbers(Pair p)
{
// implementation
}
public String toString()
{
return "Pair: ("+ x +","+ y +")";
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!