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 of the following is NOT a major type of crime reported to the IC3.
mezya [45]
I believe malware fraud, c. 


5 0
4 years ago
Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: *
MrRa [10]

Answer:

Following are the code to this question:

b= input()#defining b variable for input character value

h= input()#defining h variable for input character value

b_width=6#defining b_width variable that holds an integer value 6

r1 = ' ' * b_width+h#defining r1 variable that calculates hash lines

r2 = b*b_width+h*2#defining r3 variable that calculates 6 asterisk and 2 hash line  

r3 = b*b_width+h*3#defining r3 variable that calculates 6 asterisk and 3 hash line

print(r1)#print r1 variable value

print(r2)#print r2 variable value

print(r3)#print r3 variable value

print(r2)#print r2 variable value

print(r1)#print r1 variable value

Output:

please find the attachment.

Explanation:

In the given python code, three variable "b,h, and b_width" is declared, in which "b_width" holds an integer variable "6" and variable "b and h" is used to an input character value.  In the next line, "r1, r2, and r3" is declared, that holds arrowhead values which can be defined as follows:

  • In the "r1" variable, it stores space with b_width variable and one h variable value.
  • In the "r2" variable it stores b_width and 2*h variable value.
  • In the "r3" variable it stores b_width and 3*h variable value.

At the last, it prints the "r1, r2, and r3" variable value and for arrowheads,  it follows the above program code.

6 0
3 years ago
What are the benefits of automating a process? Choose all that apply.
taurus [48]

Answer:

All except It makes a company look modern.  

Explanation:

3 0
3 years ago
What format are a setups program file in before executed?
UkoKoshka [18]
.EXE as they are executable programs.  However, it depends on the operating system
6 0
3 years ago
A __________ is a device that allows a computer, which works with digital information, to communicate over lines that use analog
navik [9.2K]

Answer:

MODEM(Modulator Demodulator)

Explanation:

A modem is a device used in data communication that allows analog signal to be sent over a telephone line.

The modem works by converting the analog signal into digital data that the computer understands. The digital data is converted back to its original form at the receiver end.

Modem modulates analog signal from a telephone line to digital data the computer can understand. also, at the receiver end, it demodulates the digital data back to its original analog signal.

3 0
4 years ago
Other questions:
  • Using Python
    14·1 answer
  • Behaving in an acceptable manner in a workplace environment is referred to as workplace etiquette.
    12·2 answers
  • 5. Why would you want to wear white or light colors on a summer day?
    5·1 answer
  • WordArt styles allow you to add ____.
    9·1 answer
  • George enters the types of gases and the amount of gases emitted in two columns of an Excel sheet. Based on this data he creates
    6·1 answer
  • Is there anyone that knows how to work in Microsoft Access and someone that could help me on my test at 11 30am?​
    7·1 answer
  • The response from a Google Form can be seen in how many ways?
    10·1 answer
  • So im new how exactly does this point system work???​
    6·1 answer
  • What type of task can be defined to allow you fine-grained control over the management tasks a user can perform in an OU
    14·1 answer
  • As data travels further over a wavelength or frequency, what goes down?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!