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
The email application used by Jim’s office is sending emails with viruses attached to them to user’s computers. What step should
Finger [1]
Delete the program and install a new software.
5 0
2 years ago
Read 2 more answers
An intranet is a way for a company or organization to protect copyrighted and other important information?
Korolek [52]

If this is true or false, it would be true

Hope this helps

-AaronWiseIsBae

4 0
3 years ago
Read 2 more answers
Digital rights include the right to
faltersainse [42]
D. Speak your ideas with respect on the internet .
7 0
2 years ago
______ is the software that blocks a user from being able to access your computer.
antiseptic1488 [7]
The answer is firewall. It is a network security device that observes inbound and outbound network traffic and chooses whether to allow or block specific traffic based on a well-defined set of security rules. Firewalls have been a first line of protection in network security for over 25 years. The firewall present a barrier between measured and secured internal networks that can be trusted and untrusted outside networks, for example the Internet. A firewall can be software, hardware, or even both.
8 0
3 years ago
Write a program that inputs numbers and keeps a
rjkz [21]

I've included my code in the picture below. Best of luck.

3 0
3 years ago
Other questions:
  • Henry uploaded the photos of his birthday to a cloud storage system. He feels that it’s a safe option for data storage. His frie
    12·1 answer
  • A way to have cells in your spreadsheet change formats based on the value of the cells is called ________.
    8·1 answer
  • What does computer means?
    13·2 answers
  • What are two constraints that continuous-media files have that conventional data files generally do not have?
    12·1 answer
  • When one user could perform a query to determine which recordings had a track length of four minutes or more, and another user c
    9·1 answer
  • Why would you use quotation marks in a search string when conducting an internet search?
    12·1 answer
  • Which of the following is a valid c++ identifier a. mouse b. _int c. 2_stop d. float​
    10·1 answer
  • Write the importance of program in computer​
    9·1 answer
  • Firewalls are available as a special hardware device or as software. A firewall will block packets of information that are from
    7·1 answer
  • Briefly describe the working of computer processing system?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!