-
Notifications
You must be signed in to change notification settings - Fork 0
/
Keyboard.java
52 lines (41 loc) · 1.17 KB
/
Keyboard.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package gestionnairedetache;
import java.io.*;
import java.util.Scanner;
import java.util.Vector;
/**
*
* @author Msani
*/
public class Keyboard {
public static String getString() // Lire un String
{
String string = "";
char charactere ='\0';
try {
while ((charactere = (char) System.in.read()) !='\n')
{
if (charactere != '\r') string = string + charactere;
}
}
catch (IOException e)
{
System.out.println("Erreur de saisi : " + e.getMessage());
}
return string;
} // fin de S()
public static int getEntier() {
Scanner keyboard = new Scanner(System.in);
int identifiant;
do {
while (!keyboard.hasNextInt()) {
System.out.println("Vous n'avez pas entre un entier");
System.out.print("Veuillez entrer un entier : ");
keyboard.next();
}
identifiant = keyboard.nextInt();
if(identifiant < 0)
System.out.print("Veuillez entrez un entier positif : ");
} while (identifiant < 0);
return identifiant;
}
}