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
It is important to name your files in a variety of formats. true or false
blsea [12.9K]

True.You can bold important things or italicize them to make them more visible so you can find them easier and more efficiently.

<em>IMPORTANT FILES </em>pops out more than IMORTANT FILES

Good Luck :)

<em>Klicker</em>

3 0
3 years ago
Read 2 more answers
Assign listNodes with all elements with a clasa name prog-lang
ra1l [238]

Using the knowledge in computational language in JAVA it is possible to write a code that Assign listNodes with all elements with a clasa name prog-lang

<h3>Writting in JAVA:</h3>

let listNodes;

 //assigning listNodes with all elements with a class name of 'special-language'

  listNodes = document.getElementsByClassName('special-language');

 //for loop to traverse all node in listNodes and print every element in it with class name special-language

 for (let i = 0; i < listNodes.length; i++) {

     console.log(listNodes[i].innerHTML);

 }

See more about JAVA at brainly.com/question/12975450

#SPJ1

8 0
1 year ago
An airline company would like to easily locate lost luggage. What technology would make it easier for them to locate the luggage
viktelen [127]

R.F.ID Radio  frequency identification  

3 0
3 years ago
Read 2 more answers
failed logins or instances of denial of access to restricted files may be indicators of compromise. suggest where records of suc
algol [13]

As forensic evidence of suspected intrusions on a host system or network, indicators of compromise (IOCs) are used.

<h3>What is indicators?</h3>

System administrators and information security (InfoSec) experts can identify malicious activity such as intrusion attempts using these artifacts. IOCs are used by security researchers to more thoroughly examine the methods and behaviour of a certain malware.

IOCs also offer useful threat intelligence that can be disseminated around the community to help organizations develop their incident response and remediation plans.

Some of these artifacts can be seen on the system's event logs, time-stamped entries, apps, and services. Various tools that monitor IOCs are also used by infosec experts and IT/system administrators to help mitigate, if not stop, breaches or assaults.

Therefore, As forensic evidence of suspected intrusions on a host system or network, indicators of compromise (IOCs) are used.

To learn more about indicators, refer to the link:

brainly.com/question/28093573

#SPJ1

4 0
1 year ago
What does lurch mean
o-na [289]

Answer:

lurch means make an abrupt, unsteady, uncontrolled movement or series of movements; stagger.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Regarding an intrusion detection system (IDS), stateful matching looks for specific sequences appearing across several packets i
    9·1 answer
  • If an author is creating a reference list and wants the second and succeeding lines indented for a reference, they should select
    13·2 answers
  • A software process describes the interrelationship among the phases by expressing their order and frequency, but does not define
    14·1 answer
  • which of the following memory types cannot store the data for information permanently Ram chachi Flash Memory hard disk​
    8·1 answer
  • Here's a better picture of my pc mouse and keyboard​
    5·2 answers
  • What are 3 software programs for mobile computing?
    10·1 answer
  • A _____ is a computer that is deliberately set up to be easily hacked into.
    10·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
  • How to create drop down list in excel with multiple selections.
    13·2 answers
  • You have an application that renders videos for your online business. You want to make sure that the application continues to re
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!