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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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