Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Line Class Field Summary Modifier and Type private Point private double private double private Point Field and Description area circumference location radius Constructor Summary Line(Point

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Line Class Field Summary Modifier and Type private Point private double private double private Point Field and Description area circumference location radius Constructor Summary Line(Point p1, Point p2) Constructor to set the start and end position of the line Method Summary Modifier and Type Method and Description double getLength() Provides the length of the line. Point getMidPoint() Provides the mid-point of a line double getslope() Provides the slope of the line. boolean isParallel(Line line) Check if a line is parallel to another line private void setLength() Calculates the length of the line. private void setslope() Calculates the slope of the line. Java.lang.Sting toString() Provide a text representation of a Line. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Field Detail start private Point start end private Point end slope private double slope length private double length Constructor Detail Line public Line(Point p1, Point p2) Constructor to set the start and end position of the line Parameters: p1 - The point where the line starts p2 - The point where the line ends Method Detail setslope private void setslope() Calculates the slope of the line. setLength private void setLength() Calculates the length of the line. getLength public double getLength() Provides the length of the line. Returns: length of the line segment getslope public double getslope() Provides the slope of the line. Returns: slope of the line segment isParallel public boolean isParallel(Line line) Check if a line is parallel to another line Parameters: line - Line segment to compare to Returns: true if the lines are parallel, otherwise false getMidPoint public Point getMidPoint() Provides the mid-point of a line Returns: Point toString public java.lang.String toString() Overrides: toString in class java.lang.Object Class Circle public class Circle extends java.lang.Object Circle class represents a circle objects. Each circle has a radius, location, area, and circumference. Author: Student name Field Summary Fields Modifier and Type private double private double private Point private double Field and Description area circumference location radius Constructor Summary Circle(doubler) Constructor which sets the radius and sets the location to (0.0,0.0) Method Summary Modifier and Type double Method and Description getArea) Provides the area of the circle. double double boolean private void getCircumference) Provides the circumference of the circle. getRadius() Provides the radius of the circle. isPointinside(Point p) Tests if the a given point is inside of the circle, returns true if it is and false if it isn't setArea() Calculates and sets the area of the circle setCircumference() Calculates and sets the circumference of the circle setLocation(Point p) Sets location of the Circle to a new point setRadius(doubler) Modifies the radius of the circle. void void void Java.lang.Sting toString() Provide a text representation of a Circle. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Field Detail location private Point location radius private double radius area private double area circumference private double circumference Constructor Detail Circle public Circle(double r) Constructor which sets the radius and sets the location to (0.0,0.0) Parameters: r- The radius of the circle Method Detail setRadius public void setRadius(double r) Modifies the radius of the circle. Parameters: r-radius setLocation public void setLocation(Point p) Sets location of the Circle to a new point Parameters: p - Point at the centre getRadius public double getRadius() Provides the radius of the circle. Returns: radius getArea public double getArea) Provides the area of the circle. Returns: area of the circle getCircumference public double getCircumference() Provides the circumference of the circle. Returns: circumference of the circle setArea private void setArea) Calculates and sets the area of the circle setCircumference public void setCircumference) Calculates and sets the circumference of the circle isPointinside public boolean isPointinside(Point p) Tests if the a given point is inside of the circle, returns true if it is and false if it isn't Parameters: p - Point to check Returns: true if inside, else false toString public java.lang.String toString() Provide a text representation of a Circle. Overrides: toString in class java.lang.Object Returns: circle information Problem Description - Analytic Geometry You have been asked to create an Object Oriented program to help review analytical geometry for Grade 10 math students. Create a Java project. LastnameShapes (eg. SmithShapes) Create a package: lastname.firstname (eg. smith.john) You project should contain the following 4 classes: Point Line Circle IMPORTANT NOTE: Note that some of the classes require the implementation of equals( (as discussed in class) and they all require a toString method implementation Point, Line, and Circle classes must match the Javadoc and specifications (last page) as provided in the docx files of this assignment Driver Shapeland You can recreate the sample driver output on next page (no need to ask for input from the user) Your solution should incorporate proper object-oriented principles such as code reuse, decomposition (cohesive methods) and data encapsulation. Each class and all of its methods should include Javadocs. Driver Shapeland Your driver should be able to Create Points and modify an existing point display the coordinates of a Point display if2 Point objects are colocated display the distance from the point object to the origin display the distance between 2 Point objects Create Lines display the length, slope, and the start and end points of the line segment display if2 Line objects are parallel determine the mid-point of a line segment Create Circles / modify a Circle with a different location display the details of a circle: radius, center point display if a point is inside or outside of a circle (if the point is on the circle it is inside) Example output of a Test Driver 8***88***** Scenario 1* 8********** Point 1 is (2.0,2.0) Point 2 is (3.0,3.0) Distance of point 1 from origin is: 2.83 Distance of point 2 from origin is: 4.24 Line (2.0.2.0) to (3.0,3.0) Length:1.4142 Slope: 1.0000 The mid-point of this line segment p1-p2 is: (2.5.2.5) The 2 points are different. Circle Radius: 2.0 the centre is (1.0,1.0) Area of the circle is 12.57 Circumference of the circle is 12.57 Point 1 is inside the circle. Point 2 is not inside the circle. *********** Scenario 2* 8****88***** Point 1 is (1.0,1.0) Point 2 is (1.0,1.0) The 2 points are the same. Distance of line segment p1-p2 is: 0.00 Circle Radius: 4.0 the centre is (4.0,0.0) Area of the circle is 50.27 Circumference of the circle is 25.13 Point 1 is inside the circle. *********** Scenario 3* *********** Line (2.0,2.0) to (3.0,3.0) Length:1.4142 Slope: 1.0000 Line (1.0,1.0 to 6.0.6.0) Length:7.0711 Slope: 1.0000 Parallel. Point instance variables x: double y: double methods Point() - constructor Point (double, double) - constructor mutator method setPosition double double) accessor methods getXvalue(): double get Yvalue(): double distanceFrom Origin(): double calculates the distance from the origin (0,0) distanceFrom(Point): double calculates the distance between 2 Points equals(Object): boolean retums true if the point object is collocated toString0 : String Line instance variables start: Point end : Point slope: double length: double methods Line (Point, Point) - constructor getLength: double calculates the length of a line segment get Slope(): double calculate the slope getMidPoint: Point calculates and returns a mid-point isParallel Line): boolean retums true if 2 line segments are parallel toStringo:String Circle instance variables location : Point - center of the circle radius: double-radius of the circle methods Circle(radius) - default location of (0,0) mutator methods setRadius(double) setLocation Point accessor methods getRadius: double getAreal: double getCircumference: double isPointInside(Point) : boolean toString: String Point Class Field Summary Modifier and Type private double private double Field and Description Y Constructor Summary Point() Constructor if the objects contains no arguments upon instantiation, sets the point to (0.0,0.0) Point(double x, double y) Constructor if there are 2 arguments upon instantiation. Method Summary Modifier and Type Method and Description double distanceFrom(Point p) Calculates and returns the distance that the point is from another point double distance From Origin() Calculates and returns the distance from the origin that the point is boolean equals(java.lang.Object o) Checks if 2 points have equals x, y positions double getXvalue() Returns the x value of the point double setPosition(double x, double y) Changes the position of the point to the users desired position Java.lang.Sting toString() Provide a text representation of a point. Methods inherited from class java.lang. Object clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait getYvalue public double getYvalue() Returns the y value of the point Returns: The y value of the point distanceFrom Origin public double distance From Origin() Calculates and returns the distance from the origin that the point is Returns: The distance from the origin distance from public double distanceFrom(Point p) Calculates and returns the distance that the point is from another point Parameters: p - The other point to use to calculate the distance Returns: The distance between the 2 points toString public java.lang.String toString() Returns the x and y components of the point Overrides: toString in class java.lang.Object Returns: the x and y components equals public boolean equals(java.lang. Object o) Checks if 2 points have equals x, y positions Overrides: equals in class java.lang.Object Parameters: 0 - The other point to check if the points are equal Returns: If the 2 points x and y values are equal

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

Students also viewed these Databases questions

Question

3. Avoid making mistakes when reaching our goals

Answered: 1 week ago