wow le tp là
This commit is contained in:
BIN
DEV2.1/controle_machine_3/Prototype.class
Normal file
BIN
DEV2.1/controle_machine_3/Prototype.class
Normal file
Binary file not shown.
36
DEV2.1/controle_machine_3/Prototype.java
Normal file
36
DEV2.1/controle_machine_3/Prototype.java
Normal file
@@ -0,0 +1,36 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Prototype {
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1) {
|
||||
System.err.println("Veuillez entrer un nom dans la ligne de commande.");
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BufferedWriter flux = new BufferedWriter(new FileWriter(args[0] + ".java"));
|
||||
|
||||
try {
|
||||
flux.write("public class " + args[0] + " {");
|
||||
flux.newLine();
|
||||
flux.write(" public static void main(String[] args) {");
|
||||
flux.newLine();
|
||||
flux.write(" System.out.println(\"Bonjour, je m'appelle " + args[0] + ".java\");");
|
||||
flux.newLine();
|
||||
flux.write(" }");
|
||||
flux.newLine();
|
||||
flux.write("}");
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur d'écriture du fichier");
|
||||
}
|
||||
try {
|
||||
flux.close();
|
||||
} catch (IOException e3) {
|
||||
System.err.println("Erreur de fermeture du fichier");
|
||||
}
|
||||
} catch (IOException e1){
|
||||
System.err.println("Erreur de création/d'ouverture de fichier");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV2.1/controle_machine_3/Test.class
Normal file
BIN
DEV2.1/controle_machine_3/Test.class
Normal file
Binary file not shown.
5
DEV2.1/controle_machine_3/Test.java
Normal file
5
DEV2.1/controle_machine_3/Test.java
Normal file
@@ -0,0 +1,5 @@
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Bonjour, je m'appelle Test.java");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user