Bonjour,
Je veux tester ma class, j'ai donc fais un programme test, tout compile, mais lorsque je veux afficher voila ce que ça écris:
--------------------Configuration: <Default>--------------------
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
public static void main (String []args)
{
int cote=1;
String coul;
//Déclaration et instancitation du premier carre
Tp3no3 carre1 = new Tp3no3 (); //1ere instance
do
{
System.out.println ("Entrez le cote du carre 1: " );
carre1.getcote();
}
while (cote >=1);
System.out.println ("Entrez la couleur du carre 1: ");
carre1.getcoul();
//Déclaration et instancitation du deuxieme carre
Tp3no3 carre2 = new Tp3no3 (); //1ere instance
do
{
System.out.println ("Entrez le cote du carre 2: ");
carre2.getcote ();
}
while (cote >=1);
System.out.println ("Entrez la couleur du carre 2: ");
carre2.getcoul ();
14 avril 2008 à 16:12
/**
* @(#)tp3no3.java
*
*
* @author
* @version 1.00 2008/4/12
*/
class Tp3no3 {
//Variables d'instances
private String coul; //Attribut d'instance de la couleur
private int cote; //Attribut d'instance des cotes
private static int nbcarre =0;
//Constructeurs
public Tp3no3 () { // Constructeur par défaut
}
public Tp3no3 (String c, int o) {
coul = c;
cote = o;
}
//Mutateur pour initialiser la couleur
public void setcoul (String c){
coul = c;
}
//Accesseur pour retourner la couleur
public String getcoul() {
return coul;
}
//Mutateur pour initialiser les cotes
public void setcote (int o){
cote = o;
}
//Accesseur pour retourner les cotes
public int getcote() {
return cote;
}
//Méthode pour afficher
public void afficher(){
System.out.println ("---Carre 1---");
System.out.println ("Périmètre: "+cote*4);
System.out.println ("Surface: "+cote*cote);
System.out.println ("Couleur: " +coul);
System.out.println ("---Carre 2---");
System.out.println ("Périmètre: "+cote*4);
System.out.println ("Surface: "+cote*cote);
System.out.println ("Couleur: " +coul);
}
}
class Tp3no3test{
public static void main (String []args)
{
int cote=1;
String coul;
//Déclaration et instancitation du premier carre
Tp3no3 carre1 = new Tp3no3 (); //1ere instance
do
{
System.out.println ("Entrez le cote du carre 1: " );
carre1.getcote();
}
while (cote >=1);
System.out.println ("Entrez la couleur du carre 1: ");
carre1.getcoul();
//Déclaration et instancitation du deuxieme carre
Tp3no3 carre2 = new Tp3no3 (); //1ere instance
do
{
System.out.println ("Entrez le cote du carre 2: ");
carre2.getcote ();
}
while (cote >=1);
System.out.println ("Entrez la couleur du carre 2: ");
carre2.getcoul ();
//Affichage
carre1.afficher();
carre2.afficher();
}
}