Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File 1 : / * * This class represents points in the plane. * / public class Point { private double x; private double y;

File 1:
/**
This class represents points in the plane.
*/
public class Point
{
private double x;
private double y;
public Point()// default constructor
{
this.x =0.0;
this.y =0.0;
}
/**
Create a Point object with the given coordinates.
@param x x-coordinate value for the new Point object
@param y y-coordinate value for the new Point object
*/
public Point(double x, double y)
{
// implementation
}
/**
Change this Point object to have the given x-coordinate.
@param newX new x-coordinate for this Point object
*/
public void setX(double newX)
{
// implementation
}
/**
Get the x coordinate of this Point object.
@return this Point's x-coordinate
*/
public double getX()
{
// implementation
}
/**
Change this Point object to have the given y-coordinate.
@param newY new y-coordinate for this Point object
*/
public void setY(double newY)
{
// implementation
}
/**
Get the y-coordinate of this Point object.
@return this Point's y-coordinate
*/
public double getY()
{
// implementation
}
/**
Determine if this Point object has the same x-coordinate
and the same y-coordinate as the given Point.
@param p a reference to a second Point object
@return true if the given Point is equal to this Point
*/
public boolean equals(Point p)
{
// implementation
}
/**
Determine which quadrant of the plane this Point is in.
Quadrant 1 has positive x and y coordinates.
Quadrant 2 has negative x coordinates and positice y coordinates.
Quadrant 3 has negative x and y coordinates.
Quadrant 4 has positive x coordinates and negative y coordinates.
Note: The positive x and y axes are in quadranr 1.
The negative x axis is in quarant 2.
The negative y axis is in quadrant 3.
@return the quadrant number of this Point object
*/
public int quadrant()
{
// implementation
}
public String toString()
{
return "Point: ["+ x +","+ y +"]";
}
}
File 2:
/**
This class represents circles in the plane.
*/
public public class Circle
{
private double radius;
private Point center;
public Circle()// default constructor
{
this.radius =0;
this.center = new Point(0,0);
}
public Circle(double r)
{
this.radius = r;
this.center = new Point(0,0);
}
/**
Create a Circle object with the given radius and center Point.
@param r radius for the new Circle object
@param c center Point for the new Circle object
*/
public Circle(double r, Point c)
{
// implementation
}
/**
Change this Circle's center point to be the given point.
@param center new center Point for the this Circle object
*/
public void setCenter(Point center)
{
// implementation
}
public Point getCenter()
{
return this.center;
}
public void setRadius(double r)
{
this.radius = r;
}
public double getRadius()
{
return this.radius;
}
/**
Translate the center of this circle by the given
amounts in the x and y directions.
@param dx how much to move the center of this Circle in the x-direction
@param dy how much to move the center of this Circle in the y-direction
*/
public void translateBy(double dx, double dy)
{
// implementation
}
/**
Translate the center of this circle to the given
amounts in the x and y directions.
@param x new x-coordinate for the center of this Circle
@param y new y-coordinate for the center of this Circle
*/
public void translateTo(double x, double y)
{
// implementation
}
public String toString()
{
return "Circle: r ="+ radius +", center =["+ center.getX()+","+ center.getY()+"]";
}
}
File 3(Read-Only)
import java.util.Scanner;
public class Tester
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int testCase = in.nextInt();
if (1== testCase)
{
Point p1= new Point();
p1.setX(4);
p1.setY(-4);
System.out.println( p1);
Point p2= new Point();
p2.setX(-4);
p2.setY(4);
System.out.println( p2);
System.out.println( p1.quadrant());
System.out.println( p2.quadrant());
System.out.println( p1.equals(p2));
}
else if (2== testCase)
{
Circle c = new Circle();
Point p = new Point();
p.setX(4);
p.setY(5);
c.setRadius(10);
c.setCenter(p);
System.out.println( c );
c.translateBy(2,-2);

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

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago