forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPLine.java
More file actions
57 lines (50 loc) · 1.58 KB
/
APLine.java
File metadata and controls
57 lines (50 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//Denisolt Shakhbulatov 10.27.2015
/* ____________________________________________
+ APLINE +
+_____________________________________________+
+ -a: int +
+ -b: int +
+ -c: int +
+_____________________________________________+
+ +APLine(a: int, b: int, c:int): +
+ +getSlope():double +
+ +isOnLine(x,y):boolean +
_______________________________________________
*/
public class APLine
{
private int a;
private int b;
private int c;
public APLine( int A, int B, int C)
{
a = A;
b = B;
c = C;
}
public double getSlope()
{
double slope = (double)-a/b;
return slope;
}
public boolean isOnLine(int x, int y)
{ int check = (a*x) + (b*y) + (c);
if (check!=0)
return false;
else
return true;
}
public static void main(String[] arg)
{
APLine line1 = new APLine(5, 4, -17);
double slope1 = line1.getSlope();
boolean onLine1 = line1.isOnLine(5,-2);
System.out.println("slope1 is assigned " + line1.getSlope());
System.out.println(line1.isOnLine(5,-2));
APLine line2 = new APLine(-25, 40, 30);
double slope2 = line2.getSlope();
boolean onLine2 = line2.isOnLine(5,-2);
System.out.println("slope2 is assigned " + line2.getSlope());
System.out.println(line2.isOnLine(5,-2));
}
}