-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonomInt.java
34 lines (29 loc) · 948 Bytes
/
MonomInt.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
package com.company.model;
import com.company.model.Monom;
public class MonomInt extends Monom {
/*
Because this class is the child for Monom, in the contrcutor i set first the power and then the coefficient.
Regarding the toString method, I display each monomial taking into the consideration the sign of the coefficient
*/
private int coeffInt;
public MonomInt(int coeffInt, int power) {
super(power);
this.coeffInt = coeffInt;
}
public int getCoeffInt() {
return coeffInt;
}
public void setCoeffInt(int coeffInt) {
this.coeffInt = coeffInt;
}
Monom monom=new Monom();
public String ToStringIntForMonom(int power){
if(coeffInt>0)
return ("+"+coeffInt + "x^"+power);
else
if(coeffInt<0)
return (coeffInt+ "x^"+power);
else
return ("+" + 0 + " ");
}
}