1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rasek [7]
2 years ago
8

Write a class called Line that represents a line segment between two Points. Your Line objects should have the following methods

: public Line(Point p1, Point p2) Constructs a new line that contains the given two points. public Point getP1() Returns this line's first endpoint. public Point getP2() Returns this line's second endpoint. public String toString() Returns a string representation of this line, such as "[(22, 3), (4, 7)]"
Computers and Technology
1 answer:
mel-nik [20]2 years ago
4 0

Answer:

import java.awt.Point;

public class Line{

private Point point1, point2;

public Line(Point p1, Point p2){

point1 = p1;

point2 = p2;

}

public Point getP1(){

return point1;

}

public Point getP2(){

return point2;

}

public String toString(){

return "[( The " + point1.x + "," + point1.y + "), (" + point2.x + "," + point2.y +")]";

}

public static void main(String args[]){

Line lineObj = new Line(new Point(7,9), new Point(6,2));

System.out.println(lineObj.toString());

}

}

Explanation:

  • Declare the points inside the class Line.
  • Initialize the getters and setters method for the class.
  • Define a toString method that returns the information in a formatted manner.
  • Inside the main method, initialize an object with some values.
  • Display the information by calling the toString method.
You might be interested in
High capacity circuits are limited by the least capable network link, which is typically the user connection. As such, it is imp
Mariana [72]
The answer is “true”
4 0
3 years ago
Suggest names for a coding club
bulgar [2K]

Answer:

  • <u>Abstract Connoisseurs.</u>
  • <u>Hypertext Assassins.</u>
  • <u>Callback Cats.</u>
  • <u>Boolean Autocrats.</u>
  • <u>Runtime Terror.</u>

Explanation:

<em><u>Hope it's help you !!</u></em>

3 0
2 years ago
If someone you don’t know asks where you go to school, what should you do
My name is Ann [436]

Answer:

Don't answer him because you don't know what he is going to do

8 0
2 years ago
After unit and integration testing are completed, _________ testing ensures that all hardware and software components work toget
raketka [301]
Testing ensures that all hardware and software components work together
5 0
2 years ago
How do I do this??? (Im in 9th)
vlabodo [156]

Answer:

No clue!

can I get brainliest tho-

8 0
3 years ago
Other questions:
  • Make the correct match.
    11·1 answer
  • Why would a brokered CD pay more than a regular CD?
    13·1 answer
  • You’re browsing the internet and realize your browser is not responding. Which of the following will allow you to immediately ex
    11·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • True or false that computers that are joined together are able to share hardware and software, but not data
    11·1 answer
  • Arrange the steps involved in natural language generation.
    9·1 answer
  • Your program analyzes complex data.
    10·1 answer
  • Discuss TWO changes in ICMP that took place with the development of IPV6 and indicate why those changes were made.
    7·1 answer
  • state an application that would be better to write c++ than java and give a rationale for your answer
    5·1 answer
  • The three main objectives of information security are.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!