Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA: Need help writing Line Class (Problem 2). class PointTest public static void main (String[] args) Point point - new Point (10,20) System . out.println(A:

JAVA: Need help writing Line Class (Problem 2).

image text in transcribed

class PointTest public static void main (String[] args) Point point - new Point (10,20) System . out.println("A: " + point.toString()); foo (point) System.out.println("B: " +point.toString O) static void foo (Point point) system . out.printin (": " + point . tostring()); point = new Point (5,6); // caution : a trick? System.out.printin("D:"point.tostring)) class Point private int x, y Point (int x, int y) { this.x = x; this . y = y;} public String toStringO return"("+x + ", "+ y+ ")" 2. (4 points) Write a complete Line class using the Point class from the previous problem. A Line is described by two points representing the two ends of the line. Your Line class should work with the following test program generating the output shown. class LineTest public static void main (String] args) Point pl-new Point (10,20) Point p2-new Point (50, 60) Line line1 = new Line (p1,p2); System.out.printin (line1.tostring O) The output of the above program should be: (10,20): (50,60)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago