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
Which carrier sense technology is used on wireless networks to reduce collisions?
skad [1K]
CSMA/CA is used on wireless networks to reduce collisions.
8 0
3 years ago
Last bittttt of points
nevsk [136]

Answer:

THANKSSS..!!! Be safe

Explanation:

6 0
3 years ago
My uh coding teacher would like the class to do little piggy with code.
Digiron [165]

Answer:

see picture below

Explanation:

I added a parameter to factor out the first bit of each sentence into a global variable. If you change for example 'pig' into 'monkey', all sentences will change.

4 0
3 years ago
Match each label to the correct location on the image match the process to its characteristics
Lera25 [3.4K]

Answer:

The 2 on the right belong in the drawing section. The left 2 being on the sketch section

Explanation:

A technical drawing is all about precision and using a computer to refine sketches.

4 0
3 years ago
What are three limitations of computer?​
Lady bird [3.3K]

Answer:

Explanation:

Three limittaions of computer are:

It requires reqular power supply to operate .

It needs instructions to perform a task.

It cannot memorize and recall.

8 0
3 years ago
Other questions:
  • I need some cool things to do with windows command prompt.
    13·1 answer
  • What’s a sign you should talk to an adult about your online time
    14·2 answers
  • PLEASE HELP
    9·2 answers
  • Write a C function (NOT A COMPLETE PROGRAM)which takes three parameters which are the cost for an item in a grocery store, the q
    12·1 answer
  • The Internet raises the bargaining power of customers most effectively by: making information available to everyone. reducing ba
    15·1 answer
  • Find and fix the error in the if-else statement. import java.util.Scanner;
    11·2 answers
  • viewRatings(string, int) Takes a username and a minimum rating value. It prints all the books that the user has rated with a val
    10·1 answer
  • Describe the conventional method of data processing​
    12·2 answers
  • Do you ever wonder what types of media you will be using five years from now or when you graduate from college or a training pro
    9·1 answer
  • What dod instruction implements the dod cui program
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!