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]
3 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]3 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
What is the theory of trouble shooting
Dmitry [639]

Answer:

Possibly the most important but hard-to-learn ability any technical individual might have is the gift to troubleshoot. For persons who are new with the expression, troubleshooting is the act of investigating and rectifying problems in any type of system. For a businessman, this might mean recognizing the source(s) of ineffectiveness in a business and suggesting a remedial course. For a doctor, this would mean accurately identifying a patient's trouble and recommending a treatment.

3 0
3 years ago
Read 2 more answers
Write the function evens which takes in a queue by reference and changes it to only contain the even elements. That is, if the q
kvv77 [185]

Answer:

Explanation:

The following code is written in Java it goes through the queue that was passed as an argument, loops through it and removes all the odd numbers, leaving only the even numbers in the queue. It does not add any more data structures and finally returns the modified queue when its done.

  public static Queue<Integer> evens(Queue<Integer> queue) {

       int size = queue.size();

       for(int x = 1; x < size+1; x++) {

           if ((queue.peek() % 2) == 0) {

               queue.add(queue.peek());

               queue.remove();

           } else queue.remove();

       }

       return queue;

   }

3 0
3 years ago
Which result would support the particle theory of light?
andriy [413]

This question is related to the emission of electrons when light shines on an metal. (Photoelectric effect)

With the classical theory, it was thought that increasing or decreasing the intensity of light would increase or decrease the kinetic energy of the electron.,

Another expected result was that time gap between when light strikes the metal and when electrons are ejected, would depend on the intensity of such light.

However, the experimental results were not consistent with the particle theory of light. So your answer is A. 

Later on this effect was correctly explained by Einstein based on Planck's findings.


8 0
3 years ago
Read 2 more answers
hona is buying a rug for her room. Store A has the rug for $45 with a 10% discount. Store B has the same rug for $46 and is offe
Fed [463]
Store b. This will have her paying 36.00 for the rug. Store A she will pay 40.50
7 0
3 years ago
What is the most difficult part of working with the Help system?
zysi [14]
A help system refers to a documentation component that usually accompany every software. It is meant to help the users when they encounter problems in the course of using the software. The most difficult part of working with the help system IS PHRASING YOUR QUESTION. A user has to use the correct words and phrases in order to get the needed help from the help system. 
5 0
3 years ago
Other questions:
  • why is it important to use a general search engine, like GOOGLE, to look up the name of the organization, institution, agency or
    7·1 answer
  • Oracion con punto focal​
    6·1 answer
  • Linda is viewing the campaign report in her Google Ads account after successfully implementing conversion tracking tags for her
    7·1 answer
  • What does NCR stand for
    12·2 answers
  • Ok so this question is kinda weird but does anyone know what google drive is. If so how do you upload a video to it?
    11·2 answers
  • Which statement uses the example type of context clue for the underlined word?
    5·2 answers
  • Which key combination should you use
    9·2 answers
  • Simple interest will always pay more interest than compound interest.
    14·1 answer
  • Which of the following is not a reason to choose a community college?
    14·1 answer
  • In a database, what term is used to describe a group of fields that are all associated with and accessed using single primary ke
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!