This commit is contained in:
Rémi Heredero 2021-12-01 16:54:11 +01:00
parent 5e523fda0b
commit 77ee242b4f
4 changed files with 116 additions and 0 deletions

View File

@ -25,6 +25,7 @@ public class App {
case FRAISE: case FRAISE:
System.out.println("Fraise"); System.out.println("Fraise");
favorite = Glace.MANGUE; favorite = Glace.MANGUE;
break;
default: default:
System.out.println("Mangue"); System.out.println("Mangue");

View File

@ -0,0 +1,84 @@
package various_tests;
import java.io.*;
import java.nio.charset.StandardCharsets;
//import java.nio.charset.spi.CharsetProvider;
//import java.util.Scanner;
//import java.nio.charset.Charset;
/**
* The Class Input is here to enter data with the keyboard.<br>
* The types below are supported by the Input class. <br><br>
* - String <br> - Integer (int) <br> - Double (double) - Boolean (boolean) <br> - Character (char) <br> <br><br>
* @see #readString()
* @see #readInt()
* @see #readDouble()
* @see #readBoolean()
* @see #readChar()
*/
public class Input
{
/**
* Reads a String from the console.
* @return The typed string
* @see java.lang.String
*/
public static String readString()
{
// VERSION PROF
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_16));
try {return stdin.readLine(); }
catch (Exception ex) { return "";}
/* // VERSION PERSO
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
*/
}
/**
* Reads an Integer from the console.
* @return The typed Integer or 0 if the typed Integer is invalid
* @see java.lang.Integer
*/
public static int readInt()
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
try { return Integer.parseInt(stdin.readLine()); }
catch (Exception ex) { return 0; }
}
/**
* Reads a Double from the console.
* @return The typed Double or 0 if the typed Double is invalid
* @see java.lang.Double
*/
public static double readDouble()
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
try { return Double.parseDouble(stdin.readLine()); }
catch (Exception ex) { return 0; }
}
/**
* Reads a boolean from the console.
* @return The typed boolean or false if the typed boolean is other than "true"
*/
public static boolean readBoolean()
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
try { return (Boolean.valueOf(stdin.readLine())).booleanValue(); }
catch (Exception ex) {return false; }
}
/**
* Reads a char from the console.
* @return The typed char or the character 0 if the typed char is invalid
*/
public static char readChar()
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
try { return stdin.readLine().charAt(0); }
catch (Exception ex) {return '\0'; }
}
}

View File

@ -0,0 +1,12 @@
package various_tests;
public class L02tests {
public static void main(String[] args) {
int x = 10;
x ^= 3;
System.out.println(x);
}
}

View File

@ -0,0 +1,19 @@
package various_tests;
import hevs.utils.Input;
public class bug_encodage {
public static void main(String[] args) {
String s = "héllo";
System.out.println(s);
s = "";
while (true) {
s = Input.readString();
System.out.println(s);
}
}
}
//commentaire pour l'exemple