Implementing line equations in a program

Assignment Help JAVA Programming
Reference no: EM13940536

A line in the plane can be specified in various ways:

by giving a point (x, y) and a slope m by giving two points (x1, y1), (x2, y2) as an equation in slope-intercept form y = mx +

b as an equation x = a if the line is vertical

Implement a class Line with four constructors, corresponding to the four cases above. Implement methods

boolean intersects(Line other)
boolean equals(Line other)
boolean isParallel(Line other)

Use the following class as your tester class:

public class LineTester
{
public static void main(String[] args)
{
Line line1 = new Line(1, 1, 0.5);
Line line2 = new Line(1, 1, 1, 2);
Line line3 = new Line(0.5, -1);
Line line4 = new Line(1);

System.out.println(line1.equals(line2));
System.out.println("Expected: false");
System.out.println(line2.equals(line4));
System.out.println("Expected: true");
System.out.println(line1.intersects(line2));
System.out.println("Expected: true");
System.out.println(line1.intersects(line3));
System.out.println("Expected: false");
System.out.println(line1.isParallel(line3));
System.out.println("Expected: true");
System.out.println(line2.isParallel(line4));
System.out.println("Expected: true");
System.out.println(line1.isParallel(line2));
System.out.println("Expected: false");
}
}

Reference no: EM13940536

Questions Cloud

Interest rate sensitivity of single cash flow increases : Just as the interest rate sensitivity of a single cash flow increases with its maturity, the interest rate sensitivity of a stream of cash flows increases with its duration. A firm's market capitalization is determined by the difference in the market..
What is wilson profit margin and debt ratio : What is Wilson's profit margin and debt ratio?
Marketing consultant for new moxy budget hotel chain : As a marketing consultant for new Moxy budget hotel chain, you have been asked to complete a strategic marketing audit to analyse both internal and external factors that are impacting on the organisations ability to develop internationally.
Explain significance of coefficient of determination measure : Explain the significance of the coefficient of determination measures for the cost formulas. Did these measures have a bearing on your answer in Requirement 1? Should they have a bearing? Why?
Implementing line equations in a program : Implement a class Line with four constructors, corresponding to the four cases above.
What is the ultimate tensile strength of the cast iron : A brittle cast iron bar is heated to 140°C and then rigidly clamped so that it cannot contract when cooled. The bar is seen to fracture when the temperature has fallen to 80°C. What is the ultimate tensile strength of the cast iron?
Determine why people make the ethical decisions : Behavioral ethics is a new field drawing on behavioral psychology, cognitive science and related fields to determine why people make the ethical decisions, both good and bad, that they do.
What if passenger in your car has drugs and does not claim : What if the passenger in your car has drugs and does not claim them? The owner of the vehicle is charged. will the owner of the vehicle lose the vehicle?
Determine the tensile stress in the component : Determine, the tensile stress in the component when first loaded, the temperature at which the stress will be zero if the component is rigidly held at its extended length.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program that plays the memory matching game

Create a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digits each - output a large number of newlines to force the old board.

  Understand actual communication with an smtp server

Understand actual communication with an SMTP server can be achieved using TCP Sockets and understand the development of a graphical user interface (GUI) and use of event handling.

  Tese 14 questions covers java class array link list

these 14 questions covers java class array link list generic class please read carfullynbspnbsp1. suppose we have a

  The user enters an invalid value for hours

Write a program that prompts the user to enter time in 12-hour notation. The program then outputs the time in 24-hour notation. Your program must contain three exception classes: InvalidHrExcep, InvalidMinExcep, and InvalidSecExcep. If the user enter..

  Statements to print a label

Add the statements to print a label in the following format (the numbers in the example output are correct for input of $4.25 per pound and 41 ounces). Use the formatting object money to print the unit price and total price and the formatting object ..

  Virtual machine forensics

Determine what you perceive to be the greatest challenge when dealing with virtual machines from a system forensics perspective. Provide a rationale with your response.

  Inheritancedemo

Create a New Project named InheritanceDemo . 2. Create a new class called Person and cut and paste the Person.java file from Blackboard into the class. Create a new class called Student and cut and paste the Student.java file from Blackboard into the..

  Write a program that reads a set of floating-point

Write a program that reads a set of floating-point data values from the input.

  Write a number guessing game in java

ou have to write a number guessing game in Java. The program should have three difficulty levels, each one having a different maximum number. After the user selects a difficulty,

  Coin change program

coin change program. Make change using fewest number of coins. I'm attempting dynamic programming and i may be misunderstanding the algorithm

  Implement a singly linear linked list

Prepare a C++ using visual studios program to implement a singly linear Linked List - You need to implement singly link list in C++.

  Describe stringbuffer class in java

Describe StringBuffer class in java. List all the functions relevant to it and explain any five of them.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd