Answered step by step
Verified Expert Solution
Question
1 Approved Answer
WRITTEN IN JAVA. Notes: Assume that the classes listed in the Quick Reference found in the Appendix have been imported where appropriate. Unless otherwise noted
WRITTEN IN JAVA.
Notes:
Assume that the classes listed in the Quick Reference found in the Appendix have been imported where
appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are not null and that
methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in
classes defined in that question. Writing significant amounts of code that can be replaced by a call to one
of these methods may not receive full credit.
An APLine is a line defined by the equation where a is not equal to zero, is not equal to zero,
and and are all integers. The slope of an APLine is defined to be the double value A point
represented by integers and is on an APLine if the equation of the APLine is satisfied when those and
values are substituted into the equation. That is a point represented by and is on the line if is equal
to Examples of two APLine equations are shown in the following table.
Assume that the following code segment appears in a class other than APLine. The code segment shows an
example of using the APLine class to represent the two equations shown in the table.
APLine line new APLine ;
double slopel linel.getslope ; slopel is assigned
boolean onLineineisonLine ; true because
APLine line new APLine ;
double slopeinegetSlope ; slope is assigned
boolean onLine ine isonLine false because
Write the APLine class. Your implementation must include a constructor that has three integer parameters that
represent and c in that order. You may assume that the values of the parameters representing a and b are not
zero. It must also include a method getSlope that calculates and returns the slope of the line, and a method
isOnLine that returns true if the point represented by its two parameters and in that order is on the APLine
and returns false otherwise. Your class must produce the indicated results when invoked by the code segment
given above. You may ignore any issues related to integer overflow.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started