-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuadratic.java
71 lines (50 loc) · 902 Bytes
/
Quadratic.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package L1_P_five;
public class Quadratic {
private int a;
private int b;
private int c;
public Quadratic(int a, int b, int c) {
super();
this.a = a;
this.b = b;
this.c = c;
}
public Quadratic(){
this.a=0;
this.b=0;
this.c=0;
}
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public int getB() {
return b;
}
public void setB(int b) {
this.b = b;
}
public int getC() {
return c;
}
public void setC(int c) {
this.c = c;
}
public void change(int set){
setA(a);
setB(b);
setC(c);
}
public int cal(int x){
return (int) (a*Math.sqrt(x)) + b*x + c;
}
public static Quadratic sum(Quadratic q1, Quadratic q2 ){
return new Quadratic (q1.getA() +q2.getA(), q1.getB() + q2.getB() , q1.getC() + q2.getC());
}
@Override
public String toString() {
return a + "x^2 + " + b + "x + " + c ;
}
}