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
How will you swap pictures between a Publication page and the scratch area​
tamaranim1 [39]

Answer:

To move a picture from your publication to the scratch area, click and drag a picture off of a publication page. Then drop it into the scratch area in Publisher.

hope it helped you..

4 0
1 year ago
_____ rows indicate that there is different formatting for odd and even rows.
Sladkaya [172]
Banded rows indicate that there are different formatting for odd and even rows.
5 0
3 years ago
Which building-block feature is available in the Text grouping on the Insert tab?
saveliy_v [14]

Answer:

Business information

Explanation:

The building blocks are durable objects for content like corporate material, headings, timetables, and gallery advertising. The user can retrieve and utilize the building blocks at any time. The user can also design, saves, categorize and enter a description of their own building blocks, and tag them with keywords to help them find easily. 

Business information is one of the main features of the building block galleries that is found on the insert tab in text group.

3 0
3 years ago
How to remove special formatting from a table in word.
ch4aika [34]

Answer:

Clear Format

Explanation:

7 0
2 years ago
Some students are studying the amount of pollution in a river They are using a computer to measure the pollution level using sen
Tpy6a [65]

Answer:

optical sensors

Explanation:

optical sensors measure the amount of gases like carbon dioxide and carbon monoxide in the air

4 0
2 years ago
Other questions:
  • The true or false questions.
    5·1 answer
  • A(n) ________ address is a temporary ip address assigned from an available pool of ip addresses.
    12·1 answer
  • The ________________ command tests connectivity by sending an echo request to a remote computer.
    14·1 answer
  • ____ is a utility that can verify that TCP/IP is installed, bound to the NIC, configured correctly, and communicating with the n
    11·1 answer
  • What is the color difference between the iMac and iMac Pro
    14·2 answers
  • Who distributes IP Address?
    10·1 answer
  • Victor works for a telemarketing company that is on a very tight budget. He has been tasked with finding a method for the compan
    7·2 answers
  • Despite the rise of messaging apps and other forms of social media, these efforts are focused on consumer efforts, with corporat
    7·1 answer
  • Create another method: getFactorial(int num) that calculates a Product of same numbers, that Sum does for summing them up. (1,2,
    7·1 answer
  • Task 2: Typing a School Speech
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!