Probleme de compilation
sami
-
sami -
sami -
Bonjour,s'il vp aider moi pour resoudre ce probleme:
voici la class complexe
import java.math.*;
class Complexe implements Comparable {
private float x;
private float y;
public double calculModule(){
return Math.sqrt(x*x+y*y);
}
voici la methode inferieure qu'est defini ds l'interface Comparable et implementee ds la class Complexe
public boolean inferieur(Object o){
if(((Complexe)o).calculModule()<this.calculModule())
return true;
else
return false;
}
public boolean egal(Object o){
if(((Complexe)o.calculModule())==this.calculModule())
return true;
else
return false;
}
cannot resolve symbol
symbol : method sqrt (float)
location: class Math
return Math.sqrt(x*x+y*y);
^
inconvertible types
found : Object
required: Complexe
if(((Complexe)o).calculModule()<this.calculModule())
^
operator == cannot be applied to Complexe,double
if(((Complexe)o.calculModule())==this.calculModule())
^
je veu savoir pourquoi et donnez moi un autre solution pour implement ces methodes.
voici la class complexe
import java.math.*;
class Complexe implements Comparable {
private float x;
private float y;
public double calculModule(){
return Math.sqrt(x*x+y*y);
}
voici la methode inferieure qu'est defini ds l'interface Comparable et implementee ds la class Complexe
public boolean inferieur(Object o){
if(((Complexe)o).calculModule()<this.calculModule())
return true;
else
return false;
}
public boolean egal(Object o){
if(((Complexe)o.calculModule())==this.calculModule())
return true;
else
return false;
}
cannot resolve symbol
symbol : method sqrt (float)
location: class Math
return Math.sqrt(x*x+y*y);
^
inconvertible types
found : Object
required: Complexe
if(((Complexe)o).calculModule()<this.calculModule())
^
operator == cannot be applied to Complexe,double
if(((Complexe)o.calculModule())==this.calculModule())
^
je veu savoir pourquoi et donnez moi un autre solution pour implement ces methodes.
A voir également:
- Probleme de compilation
- Breach compilation c'est quoi - Guide
- Erreur de compilation projet ou bibliothèque introuvable - Forum VB / VBA
- Message d'erreur Excel projet ou bibliotheque introuvable ! - Forum Excel
- Problème Compilation Dev-C++ - Forum C++
- Must declare a named package because this compilation unit is associated to the named module - Forum Java
3 réponses
Salut,
je sais pas si tu peux faire les opérations directement dans le paramètre de la fonction.
Dans ta classe Complexe, déclare un private float z, et ta fonction calculModule donnerait ça :
public double calculModule(float x, float y){
z=x*x+y*y;
return Math.sqrt(z);
}
je sais pas si tu peux faire les opérations directement dans le paramètre de la fonction.
Dans ta classe Complexe, déclare un private float z, et ta fonction calculModule donnerait ça :
public double calculModule(float x, float y){
z=x*x+y*y;
return Math.sqrt(z);
}