Que faire avec les erreurs du ptit prog suivant ?
public class Nat{
int n;
public Nat(int n){
this.n=n;
}
public int getValue(){
return n;
}
public Nat succ(){
return new Nat(n++);
}
public Nat pred()throws NatNegatifException{
if(this.n<1) throw new NatNegatifException();
return new Nat(n--);
}
public boolean inf(Nat n){
return this.n<n.getValue();
}
public boolean equals(Object n){
return this.n==((Nat)n).getValue();
}
public boolean nul(){
return n==0;
}
public String toString(){
return ""+n;
}
public Nat add(Nat n){
int a=this.n, b=n.getValue();
Nat som=new Nat(a), i=new Nat(0);
while(!i.inf(n)){
i.succ();
som.succ();
}
return som;
}
public Nat sous(Nat n)throws NatNegatifException{
if(this.inf(n)) throw new NatNegatifException();
int a=this.n, b=n.getValue();
int s=a , i=b ;
while(i!=0){
i--;
s--;
}
return new Nat(s);
}
public Nat prod(Nat n){
int a=this.n, b=n.getValue();
int p=0 , i=b, j=a ;
while(i!=0){
i--;
p=p+a;
}
return new Nat(p);
}
public Nat div(Nat n)throws DivisionZeroException{
if(n.getValue()==0) throw new DivisionZeroException();
int a=this.n, b=n.getValue();
int r=a, q=0 , j=b ;
while(r>=b){
r=r-j;
q++;
}
return new Nat(q);
}
public Nat mod(Nat n)throws DivisionZeroException{
if(n.getValue()==0) throw new DivisionZeroException();
int a=this.n, b=n.getValue();
int r=a, q=0 , j=b ;
while(r>=b){
r=r-j;
q++;
}
return new Nat(r);
}
public Nat rac(){
int v=1, rac=0 , car=1 , i=n ;
while(car<=i){
rac++;
v=v+2;
car=car+v;
}
return new Nat(rac);
}
}