Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java programing this is the question and this is the output and this is my half answer please help me to complete my homework Implement

java programing this is the question
image text in transcribed
and this is the output
image text in transcribed
and this is my half answer
please help me to complete my homework
image text in transcribed
image text in transcribed
image text in transcribed
Implement the following classes: 1) Class Point that has the following properties: - Two instance variables x and y (of type integer) that represent the xy coordinate of a point. - A default constructor that initializes the instance variables to the default values. - A constructor that initializes the instanoe variables to the values specified as paramelers. - Set and get methods for the instance variables. - A method distance that takes a reference to a Point object nypoint as a parameter and returns the distance between this Point to the given instance mypoint, passed as a parameter. - A method distance that takes two inleger parameters and returns the distance between this Point to the given point with cocrdinates speoified in the parametors. - Note that the distance between the two points (x1,y1) and (x2,y2) is given as (x1x2)2+(y1y2)2 - A method tostrlng that returns string representation of a Point given as point (x,y). 2) Class Line that has the following properties: - Two instance variables start and end that are references to Point objects. The two points represent the end points of a Line segment. - A class (static) variable counter (of type integer) that specifies the number of Line objects created. - A constructor that initializes the instance variables start and end to the references specilied as parameters and increments the static variable counter by one to indicate. that a Line has been created. - A static method getcounter that returns the static variable counter. - A method n 1ope that returns the slope of the Line. - Note that the siope of the Line with the two end points (x1,y1) and (x2,y2) is given as x1x2y1y2 - A method is Parallel that takes a reference to a Line object myLitie as a parameter and returns true if the two lines are paralet or false otherwise. The two lines are parallel If they have the same slope. - A method tostring that returns the string representation of a Line given as Line from (x1,y1) to (x2,y2). 2) Class LineTest that has a main method to test your classes. The main method should do the following: - Create an array of three relerences to Line objects. - Input the two end points of each Line, create the objects and store them in the array. - Print the number of lines created. - Use a loop to print the string representation of each line and its slope. - Use a loop to check whether the frst line in the array is parallel to any other line and show the results. - Create two Point objects and test the two versions of the distance method. Sample Output Line 1 Enter xy coordinate of the start point: 12 Enter xy coordinate of the end point: 34 Line 2 Enter xy coordinate of the start point: 48 Enter xy coordinate of the end point: 26 Line 3 Enter xy coordinate of the start point: 21 Enter xy coordinate of the end point: The number of lines created is 3 Line from point (1,2) to point (3,4) the slope is 1.00 Line from point (4,8) to point (2,6) the slope is 1.00 Line from point (2,1) to point (5,6) the slope is 1.67 Line from point (1,2) to point (3,4) is parallel to Line from point (4, 8) to point (2,6) The distance between point (1,2) and point (2,4) is 2.24 The distance between point (1,2) and point (2,4) is 2.24 public class Point \{ private double x,y; public Point() \{ x=y=0; public Point (double x, double y ) f. super( ); this. x=x; this. y=y; public double getX() \{ return x; public void setX(double x ) \{ this. x=x; public double getY() \{ return y; public void sety(double y) this.y; y; public double distance(Point mypoint) \{ \{. double d=0; double xx,yy; xx=x-mypoint. x;f(x)x2 xx= Math.pow (xx,2);1(x1x2)2 yyly-aypoint y;/7x1xz yy Wath, pouv (xx,yy); return d; ) public double distance ( double 2, double y2 ) Pnint n2enw: Bhintirs w21 Problems x it Javadoc iss Dectaration

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

Apply your own composing style to personalize your messages.

Answered: 1 week ago

Question

Format memos and e-mail properly.

Answered: 1 week ago