Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * * 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
{
//implementation
}
/**
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)
{
// implement
}
/**
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)
{
//implementation
}
/**
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)
{
//implementation
}
/**
Get the x-value of this Pair object.
@return this Pair's x-value
*/
public int getX()
{
//implementation
}
/**
Change this Pair object to have the given x-value.
@param x new x-value for this Pair object
*/
public void setX(int x)
{
//implementation
}
/**
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

=+2. Why does the brand want to advertise?

Answered: 1 week ago