This commit is contained in:
parent
4ab62020a4
commit
0396ab6fc7
BIN
src/C04_Expressions/04_expressions_fr.pdf
Normal file
BIN
src/C04_Expressions/04_expressions_fr.pdf
Normal file
Binary file not shown.
16
src/C04_Expressions/C04EX0501.java
Normal file
16
src/C04_Expressions/C04EX0501.java
Normal file
@ -0,0 +1,16 @@
|
||||
package C04_Expressions;
|
||||
|
||||
import library.*;
|
||||
|
||||
public class C04EX0501 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int a = Input.readInt();
|
||||
if (a>=0) {
|
||||
System.out.println(a);
|
||||
} else {
|
||||
System.out.println(-a);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
23
src/C04_Expressions/C04EX0502.java
Normal file
23
src/C04_Expressions/C04EX0502.java
Normal file
@ -0,0 +1,23 @@
|
||||
package C04_Expressions;
|
||||
|
||||
import library.*;
|
||||
|
||||
public class C04EX0502 {
|
||||
public static void main(String[] args) {
|
||||
while (true) {
|
||||
int a = Input.readInt();
|
||||
boolean b = false;
|
||||
|
||||
if (a%2 == 0) {
|
||||
b = true;
|
||||
}
|
||||
|
||||
if(b){
|
||||
System.out.println("La variable est paire");
|
||||
} else {
|
||||
System.out.println("La variable est impaire");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
src/C05_Boucle_et_fonctions/05_loops_fr.pdf
Normal file
BIN
src/C05_Boucle_et_fonctions/05_loops_fr.pdf
Normal file
Binary file not shown.
20
src/C05_Boucle_et_fonctions/C05EX01a.java
Normal file
20
src/C05_Boucle_et_fonctions/C05EX01a.java
Normal file
@ -0,0 +1,20 @@
|
||||
package C05_Boucle_et_fonctions;
|
||||
|
||||
import library.*;
|
||||
|
||||
public class C05EX01a {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int a, b, c;
|
||||
System.out.print("Veuillez entrer la première valeur: ");
|
||||
a = Input.readInt();
|
||||
System.out.print("Veuillez entrer la deuxième valeur: ");
|
||||
b = Input.readInt();
|
||||
System.out.print("Veuillez entrer la troisième valeur: ");
|
||||
c = Input.readInt();
|
||||
int max = a>b ? a:b;
|
||||
max = max>c ? max:c;
|
||||
System.out.println(max);
|
||||
|
||||
}
|
||||
}
|
14
src/C05_Boucle_et_fonctions/C05EX01b.java
Normal file
14
src/C05_Boucle_et_fonctions/C05EX01b.java
Normal file
@ -0,0 +1,14 @@
|
||||
package C05_Boucle_et_fonctions;
|
||||
|
||||
import library.*;
|
||||
|
||||
public class C05EX01b {
|
||||
public static void main(String[] args) {
|
||||
double a = Input.readDouble();
|
||||
if (a>=0) {
|
||||
System.out.println(Math.sqrt(a));
|
||||
} else {
|
||||
System.out.println("error");
|
||||
}
|
||||
}
|
||||
}
|
12
src/C05_Boucle_et_fonctions/C05EX02.java
Normal file
12
src/C05_Boucle_et_fonctions/C05EX02.java
Normal file
@ -0,0 +1,12 @@
|
||||
package C05_Boucle_et_fonctions;
|
||||
|
||||
public class C05EX02 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int x = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
x = i+1;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/C06_Fonctions/06_functions_fr.pdf
Normal file
BIN
src/C06_Fonctions/06_functions_fr.pdf
Normal file
Binary file not shown.
19
src/C06_Fonctions/C06EX06.java
Normal file
19
src/C06_Fonctions/C06EX06.java
Normal file
@ -0,0 +1,19 @@
|
||||
package C06_Fonctions;
|
||||
import hevs.utils.Input;
|
||||
|
||||
public class C06EX06 {
|
||||
|
||||
public static int somme(int x1, int x2, int x3){
|
||||
return x1+x2+x3;
|
||||
}
|
||||
|
||||
public static double petit(double x1, double x2) {
|
||||
return x1<x2?x1:x2;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("La somme est: " + somme(Input.readInt(), Input.readInt(), Input.readInt()));
|
||||
System.out.println("Le plus petit nombre est: " + petit(Input.readDouble(), Input.readDouble()));
|
||||
}
|
||||
|
||||
}
|
BIN
src/C07_POO/C070_introduction/7_classes_et_objets.pdf
Normal file
BIN
src/C07_POO/C070_introduction/7_classes_et_objets.pdf
Normal file
Binary file not shown.
10
src/C07_POO/C070_introduction/Rectangle.java
Normal file
10
src/C07_POO/C070_introduction/Rectangle.java
Normal file
@ -0,0 +1,10 @@
|
||||
package C07_POO.C070_introduction;
|
||||
|
||||
public class Rectangle {
|
||||
int width;
|
||||
int height;
|
||||
|
||||
public int area() {
|
||||
return width * height;
|
||||
}
|
||||
}
|
25
src/C07_POO/C070_introduction/RectangleDemoBegin.java
Normal file
25
src/C07_POO/C070_introduction/RectangleDemoBegin.java
Normal file
@ -0,0 +1,25 @@
|
||||
package C07_POO.C070_introduction;
|
||||
|
||||
public class RectangleDemoBegin {
|
||||
|
||||
public static void main(String args[]) {
|
||||
Rectangle r1 = new Rectangle();
|
||||
r1.height = 4;
|
||||
r1.width = 4;
|
||||
|
||||
Rectangle r2 = new Rectangle();
|
||||
r2.height = 5;
|
||||
r2.width = 6;
|
||||
|
||||
Rectangle r3 = new Rectangle();
|
||||
r3.height = 2;
|
||||
r3.width = 2;
|
||||
|
||||
int totalArea = r1.area();
|
||||
totalArea += r2.area();
|
||||
totalArea += r3.area();
|
||||
|
||||
System.out.println(totalArea);
|
||||
|
||||
}
|
||||
}
|
BIN
src/C07_POO/C071_classes_et_objets/7_1-classes_et_objets.pdf
Normal file
BIN
src/C07_POO/C071_classes_et_objets/7_1-classes_et_objets.pdf
Normal file
Binary file not shown.
17
src/C07_POO/C071_classes_et_objets/Car.java
Normal file
17
src/C07_POO/C071_classes_et_objets/Car.java
Normal file
@ -0,0 +1,17 @@
|
||||
package C07_POO.C071_classes_et_objets;
|
||||
|
||||
public class Car {
|
||||
String color = "";
|
||||
String type = "";
|
||||
int maxSpeed;
|
||||
|
||||
public String getStringRepresentation() {
|
||||
String s = type;
|
||||
s += " ";
|
||||
s += color;
|
||||
s += ", vitesse max: ";
|
||||
s += maxSpeed;
|
||||
s += "km/h";
|
||||
return s;
|
||||
}
|
||||
}
|
16
src/C07_POO/C071_classes_et_objets/Ex1–La_classe_Person.txt
Normal file
16
src/C07_POO/C071_classes_et_objets/Ex1–La_classe_Person.txt
Normal file
@ -0,0 +1,16 @@
|
||||
Objectifs
|
||||
Créer une classe
|
||||
Tester la classe
|
||||
Enoncé du problème
|
||||
Nous souhaitons créer une classe devant représenter une personne. Une personne possède les attributs suivants :
|
||||
Nom
|
||||
Prénom
|
||||
Âge
|
||||
Taille
|
||||
|
||||
Travail à faire
|
||||
Créer la classe Person avec les attributs nécessaires
|
||||
Dans une autre classe qui contiendra votre main :
|
||||
Instanciez une première personne de 19 ans, nommée "John Doe", mesurant 1.75 m
|
||||
Instanciez une second personne de 122 ans, nommée "Mathusalem", dont la taille est de 1.20 m
|
||||
Vérifiez que tout fonctionne bien avec ces deux objets. Notamment, essayez d’imprimer le nom des personnes lorsque vous les aurez instanciées.
|
23
src/C07_POO/C071_classes_et_objets/Ex2–La_classe_Car.txt
Normal file
23
src/C07_POO/C071_classes_et_objets/Ex2–La_classe_Car.txt
Normal file
@ -0,0 +1,23 @@
|
||||
Objectifs
|
||||
Créer une classe
|
||||
Tester une classe
|
||||
Tester les méthodes de classes existantes (avec la classe String)
|
||||
Enoncé du problème
|
||||
On souhaite réaliser une classe pour modéliser une voiture. Pensez quels types d’attributs cette classe doit posséder, sachant
|
||||
Un véhicule est caractérisé par sa couleur, son nom et sa vitesse maximale.
|
||||
Un véhicule possède une méthode permettant de retourner sa représentation textuelle. Par exemple le code suivant :
|
||||
|
||||
Car c1 = new Car();
|
||||
c1.color = "bleue";
|
||||
c1.maxSpeed = 250;
|
||||
c1.type = "Ford Raptor";
|
||||
System.out.println(c1.getStringRepresentation());
|
||||
|
||||
doit afficher
|
||||
|
||||
Ford Raptor bleue, vitesse max : 250 km/h
|
||||
|
||||
Travail à faire
|
||||
Implémentez la classe Car selon les instructions ci-dessus.
|
||||
Testez votre classe Car dans une autre classe qui contiendra le main.
|
||||
Vérifiez que l’affichage est bien correct.
|
13
src/C07_POO/C071_classes_et_objets/Exercice2.java
Normal file
13
src/C07_POO/C071_classes_et_objets/Exercice2.java
Normal file
@ -0,0 +1,13 @@
|
||||
package C07_POO.C071_classes_et_objets;
|
||||
|
||||
public class Exercice2 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Car c1 = new Car();
|
||||
c1.color = "bleue";
|
||||
c1.maxSpeed = 250;
|
||||
c1.type = "Ford Raptor";
|
||||
System.out.println(c1.getStringRepresentation());
|
||||
|
||||
}
|
||||
}
|
19
src/C07_POO/C071_classes_et_objets/Person.java
Normal file
19
src/C07_POO/C071_classes_et_objets/Person.java
Normal file
@ -0,0 +1,19 @@
|
||||
package C07_POO.C071_classes_et_objets;
|
||||
|
||||
public class Person {
|
||||
String surname; // Nom de famille
|
||||
String name; // Prénom
|
||||
int age; // Âge
|
||||
double height; // Taille
|
||||
|
||||
public void print() {
|
||||
System.out.print(name);
|
||||
System.out.print(" ");
|
||||
System.out.print(surname);
|
||||
System.out.print(", ");
|
||||
System.out.print(age);
|
||||
System.out.print(", ");
|
||||
System.out.print(height);
|
||||
System.out.println("m.");
|
||||
}
|
||||
}
|
24
src/C07_POO/C071_classes_et_objets/exercice1.java
Normal file
24
src/C07_POO/C071_classes_et_objets/exercice1.java
Normal file
@ -0,0 +1,24 @@
|
||||
package C07_POO.C071_classes_et_objets;
|
||||
|
||||
public class exercice1 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Person john;
|
||||
john = new Person();
|
||||
|
||||
john.surname = "Doe";
|
||||
john.name = "John";
|
||||
john.age = 19;
|
||||
john.height = 1.75;
|
||||
|
||||
Person mathusalem = new Person();
|
||||
|
||||
mathusalem.name = "Mathusalem";
|
||||
mathusalem.age = 122;
|
||||
mathusalem.height = 1.2;
|
||||
|
||||
john.print();
|
||||
mathusalem.print();
|
||||
|
||||
}
|
||||
}
|
BIN
src/C07_POO/C072_constructeurs/7_2-constructeurs.pdf
Normal file
BIN
src/C07_POO/C072_constructeurs/7_2-constructeurs.pdf
Normal file
Binary file not shown.
23
src/C07_POO/C072_constructeurs/Car.java
Normal file
23
src/C07_POO/C072_constructeurs/Car.java
Normal file
@ -0,0 +1,23 @@
|
||||
package C07_POO.C072_constructeurs;
|
||||
|
||||
public class Car {
|
||||
String color = "";
|
||||
String type = "";
|
||||
int maxSpeed;
|
||||
|
||||
public Car(String type, String color, int maxSpeed){
|
||||
this.type = type;
|
||||
this.color = color;
|
||||
this.maxSpeed = maxSpeed;
|
||||
}
|
||||
|
||||
public String getStringRepresentation() {
|
||||
String s = type;
|
||||
s += " ";
|
||||
s += color;
|
||||
s += ", vitesse max: ";
|
||||
s += maxSpeed;
|
||||
s += "km/h";
|
||||
return s;
|
||||
}
|
||||
}
|
19
src/C07_POO/C072_constructeurs/Ex3–constructeur1.txt
Normal file
19
src/C07_POO/C072_constructeurs/Ex3–constructeur1.txt
Normal file
@ -0,0 +1,19 @@
|
||||
Objectif
|
||||
Ajouter un constructeur à une classe existante
|
||||
Tester une classe avec son constructeur
|
||||
Enoncé du problème
|
||||
1. Ajoutez à la classe Car définie auparavant un constructeur permettant d’instancier la voiture en une seule ligne de code, avec tous ses attributs comme ci-dessous.
|
||||
2. Utilisez ce constructeur pour créer une instance de la classe.
|
||||
|
||||
Car c1 = new Car("Ford Raptor", "bleue", 250);
|
||||
System.out.println(c1.getStringRepresentation());
|
||||
|
||||
doit afficher
|
||||
|
||||
Ford Raptor bleue, vitesse max : 250 km/h
|
||||
|
||||
|
||||
Travail à faire
|
||||
Modifiez la classe Car selon les instructions ci-dessus.
|
||||
Testez votre classe Car dans une autre classe qui contiendra le main.
|
||||
Vérifiez que l’affichage est bien correct.
|
12
src/C07_POO/C072_constructeurs/Ex4–constructeur2.txt
Normal file
12
src/C07_POO/C072_constructeurs/Ex4–constructeur2.txt
Normal file
@ -0,0 +1,12 @@
|
||||
Objectif
|
||||
Ajouter plusieurs constructeurs à une classe existante
|
||||
Tester une classe avec son constructeur
|
||||
Constater l’existance de null
|
||||
Enoncé du problème
|
||||
Ajoutez deux constructe urs à la class Person définie auparavant.
|
||||
1. Le premier permettant de définir tous les attributs en une fois.
|
||||
2. Un second constructeur ne prenant que le prénom comme argument. Ce constructeur doit appeler le constructeur avec tous les arguments. Pour les String non définis, utilisez la constante null.
|
||||
Travail à faire
|
||||
Complétez la classe Person selon les instructions ci-dessus.
|
||||
Testez votre classe Person dans une autre classe qui contiendra le main.
|
||||
Utilisez le constructeur à un argument pour instancier Mathusalem, qui n’a pas de prénom. Que se passe-t-il lorsque vous essayer d’appeler une méthode sur le prénom de votre objet, par exemple toUpperCase() qui est une méthode définie pour les String ?
|
10
src/C07_POO/C072_constructeurs/Exercice3.java
Normal file
10
src/C07_POO/C072_constructeurs/Exercice3.java
Normal file
@ -0,0 +1,10 @@
|
||||
package C07_POO.C072_constructeurs;
|
||||
|
||||
public class Exercice3 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Car c1 = new Car("Ford Raptor", "bleue", 250);
|
||||
System.out.println(c1.getStringRepresentation());
|
||||
|
||||
}
|
||||
}
|
13
src/C07_POO/C072_constructeurs/Exercice4.java
Normal file
13
src/C07_POO/C072_constructeurs/Exercice4.java
Normal file
@ -0,0 +1,13 @@
|
||||
package C07_POO.C072_constructeurs;
|
||||
|
||||
public class Exercice4 {
|
||||
public static void main(String[] args) {
|
||||
Person john = new Person("John", "Doe", 19, 1.75);
|
||||
john.print();
|
||||
|
||||
Person momo = new Person("Mathusalem");
|
||||
momo.print();
|
||||
momo.surname.toUpperCase();
|
||||
momo.print();;
|
||||
}
|
||||
}
|
30
src/C07_POO/C072_constructeurs/Person.java
Normal file
30
src/C07_POO/C072_constructeurs/Person.java
Normal file
@ -0,0 +1,30 @@
|
||||
package C07_POO.C072_constructeurs;
|
||||
|
||||
public class Person {
|
||||
String surname = ""; // Nom de famille
|
||||
String name = ""; // Prénom
|
||||
int age; // Âge
|
||||
double height; // Taille
|
||||
|
||||
public Person(String name, String surname, int age, double height){
|
||||
this.surname = surname;
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Person(String name){
|
||||
this(name, "", 0, 0);
|
||||
}
|
||||
|
||||
public void print() {
|
||||
System.out.print(name);
|
||||
System.out.print(" ");
|
||||
System.out.print(surname);
|
||||
System.out.print(", ");
|
||||
System.out.print(age);
|
||||
System.out.print(", ");
|
||||
System.out.print(height);
|
||||
System.out.println("m.");
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
14
src/C07_POO/C073_Visibilite_des_membres/Exercice5.java
Normal file
14
src/C07_POO/C073_Visibilite_des_membres/Exercice5.java
Normal file
@ -0,0 +1,14 @@
|
||||
package C07_POO.C073_Visibilite_des_membres;
|
||||
|
||||
public class Exercice5 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Triangle t = new Triangle(5, 2);
|
||||
System.out.println(t.computeArea());
|
||||
System.out.println(computeTriangleArea(t));
|
||||
}
|
||||
|
||||
public static double computeTriangleArea(Triangle t){
|
||||
return (t.base*t.hauteur)/2;
|
||||
}
|
||||
}
|
15
src/C07_POO/C073_Visibilite_des_membres/Triangle.java
Normal file
15
src/C07_POO/C073_Visibilite_des_membres/Triangle.java
Normal file
@ -0,0 +1,15 @@
|
||||
package C07_POO.C073_Visibilite_des_membres;
|
||||
|
||||
public class Triangle {
|
||||
double base;
|
||||
double hauteur;
|
||||
|
||||
Triangle(double base, double hauteur){
|
||||
this.base = base;
|
||||
this.hauteur = hauteur;
|
||||
}
|
||||
|
||||
public double computeArea(){
|
||||
return (base*hauteur)/2;
|
||||
}
|
||||
}
|
BIN
src/C07_POO/C074_modificateur_static/7_4-modificateur_static.pdf
Normal file
BIN
src/C07_POO/C074_modificateur_static/7_4-modificateur_static.pdf
Normal file
Binary file not shown.
Binary file not shown.
17
src/C07_POO/C075_autoboxing_des_types_primitifs/Main.java
Normal file
17
src/C07_POO/C075_autoboxing_des_types_primitifs/Main.java
Normal file
@ -0,0 +1,17 @@
|
||||
package C07_POO.C075_autoboxing_des_types_primitifs;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
//Integer foo = new Integer(15);
|
||||
//System.out.println(foo.toHexString(foo.intValue()));
|
||||
String s = "12";
|
||||
System.out.println(Integer.parseInt(s)+5);
|
||||
int bar = 17;
|
||||
Integer barInteger = bar;
|
||||
System.out.println(barInteger+2);
|
||||
Double foobarDouble = 3.0;
|
||||
double foobar = foobarDouble;
|
||||
System.out.println(foobar);
|
||||
|
||||
}
|
||||
}
|
BIN
src/C07_POO/string_methods.pdf
Normal file
BIN
src/C07_POO/string_methods.pdf
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
package C8tableaux.C81enum;
|
||||
package C08_Structures_de_donnees.C081_Enum;
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Hello, World!");
|
BIN
src/C08_Structures_de_donnees/C081_Enum/C081_Types_enumeres.pdf
Normal file
BIN
src/C08_Structures_de_donnees/C081_Enum/C081_Types_enumeres.pdf
Normal file
Binary file not shown.
5
src/C08_Structures_de_donnees/C081_Enum/Cat.java
Normal file
5
src/C08_Structures_de_donnees/C081_Enum/Cat.java
Normal file
@ -0,0 +1,5 @@
|
||||
package C08_Structures_de_donnees.C081_Enum;
|
||||
|
||||
public class Cat {
|
||||
|
||||
}
|
5
src/C08_Structures_de_donnees/C081_Enum/Glace.java
Normal file
5
src/C08_Structures_de_donnees/C081_Enum/Glace.java
Normal file
@ -0,0 +1,5 @@
|
||||
package C08_Structures_de_donnees.C081_Enum;
|
||||
|
||||
public class Glace {
|
||||
|
||||
}
|
7
src/C08_Structures_de_donnees/C082_Tableaux/App.java
Normal file
7
src/C08_Structures_de_donnees/C082_Tableaux/App.java
Normal file
@ -0,0 +1,7 @@
|
||||
package C08_Structures_de_donnees.C082_Tableaux;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Hello, World!");
|
||||
}
|
||||
}
|
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
package C08_Structures_de_donnees.C083_Operations_sur_tableaux;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Hello, World!");
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,5 +0,0 @@
|
||||
package C8tableaux.C81enum;
|
||||
|
||||
public class Cat {
|
||||
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package C8tableaux.C81enum;
|
||||
|
||||
public class Glace {
|
||||
|
||||
}
|
68
src/library/Dialogs.java
Normal file
68
src/library/Dialogs.java
Normal file
@ -0,0 +1,68 @@
|
||||
package library;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPasswordField;
|
||||
|
||||
/**
|
||||
* This class allows to display simple messages and have graphical interfaces to
|
||||
* enter words and characters.
|
||||
*
|
||||
* @version 2.0
|
||||
*
|
||||
*/
|
||||
public class Dialogs {
|
||||
/**
|
||||
* This function open a dialog box to enter a hidden String. The dialog box
|
||||
* asks for a String containing a minimum of one character.
|
||||
*
|
||||
* @param message
|
||||
* The message displayed to ask for the hidden String
|
||||
* @return The hidden String entered
|
||||
*/
|
||||
public static String getHiddenString(String message) {
|
||||
JPasswordField passwordField = new JPasswordField(10);
|
||||
JFrame frame = new JFrame(message);
|
||||
// prompt the user to enter their name
|
||||
JOptionPane.showMessageDialog(frame, passwordField, message, JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
String s = new String(passwordField.getPassword());
|
||||
if (s.length() > 0)
|
||||
return s;
|
||||
else
|
||||
return getHiddenString("Enter at least one character");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function open a dialog box to enter a character. This function
|
||||
* accepts only one character.
|
||||
*
|
||||
* @param message
|
||||
* The message asking for the character.
|
||||
* @return The character entered.
|
||||
*/
|
||||
public static char getChar(String message) {
|
||||
JFrame frame = new JFrame("Input a character please");
|
||||
// prompt the user to enter their name
|
||||
String s = JOptionPane.showInputDialog(frame, message);
|
||||
|
||||
if(s == null){
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if (s.length() == 1)
|
||||
return s.charAt(0);
|
||||
else
|
||||
return getChar("Just one character");
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a dialog box to display a message.
|
||||
*
|
||||
* @param message
|
||||
* The message to display.
|
||||
*/
|
||||
public static void displayMessage(String message) {
|
||||
JOptionPane.showMessageDialog(null, message, null, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
84
src/library/Input.java
Normal file
84
src/library/Input.java
Normal file
@ -0,0 +1,84 @@
|
||||
package library;
|
||||
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'; }
|
||||
}
|
||||
}
|
20
src/series/C05S03_loops/C05EX01/C05EX01a.java
Normal file
20
src/series/C05S03_loops/C05EX01/C05EX01a.java
Normal file
@ -0,0 +1,20 @@
|
||||
package series.C05S03_loops.C05EX01;
|
||||
|
||||
import library.Input;
|
||||
|
||||
public class C05EX01a {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int a, b, c;
|
||||
System.out.print("Veuillez entrer la première valeur: ");
|
||||
a = Input.readInt();
|
||||
System.out.print("Veuillez entrer la deuxième valeur: ");
|
||||
b = Input.readInt();
|
||||
System.out.print("Veuillez entrer la troisième valeur: ");
|
||||
c = Input.readInt();
|
||||
int max = a>b ? a:b;
|
||||
max = max>c ? max:c;
|
||||
System.out.println(max);
|
||||
|
||||
}
|
||||
}
|
14
src/series/C05S03_loops/C05EX01/C05EX01b.java
Normal file
14
src/series/C05S03_loops/C05EX01/C05EX01b.java
Normal file
@ -0,0 +1,14 @@
|
||||
package series.C05S03_loops.C05EX01;
|
||||
|
||||
import library.*;
|
||||
|
||||
public class C05EX01b {
|
||||
public static void main(String[] args) {
|
||||
double a = Input.readDouble();
|
||||
if (a>=0) {
|
||||
System.out.println(Math.sqrt(a));
|
||||
} else {
|
||||
System.out.println("error");
|
||||
}
|
||||
}
|
||||
}
|
12
src/series/C05S03_loops/C05EX02.java
Normal file
12
src/series/C05S03_loops/C05EX02.java
Normal file
@ -0,0 +1,12 @@
|
||||
package series.C05S03_loops;
|
||||
|
||||
public class C05EX02 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int x = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
x = i+1;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
22
src/series/C05S03_loops/C05EX03.java
Normal file
22
src/series/C05S03_loops/C05EX03.java
Normal file
@ -0,0 +1,22 @@
|
||||
package series.C05S03_loops;
|
||||
|
||||
public class C05EX03 {
|
||||
public static void wait(int ms)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(ms);
|
||||
}
|
||||
catch(InterruptedException ex)
|
||||
{
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
int x = 2147483640;
|
||||
for (int i = 0; i < 10; x++) {
|
||||
System.out.println(x);
|
||||
wait(100);
|
||||
}
|
||||
}
|
||||
}
|
10
src/series/C05S03_loops/C05EX04/C05EX04a.java
Normal file
10
src/series/C05S03_loops/C05EX04/C05EX04a.java
Normal file
@ -0,0 +1,10 @@
|
||||
package series.C05S03_loops.C05EX04;
|
||||
|
||||
public class C05EX04a {
|
||||
public static void main(String[] args) {
|
||||
int foo =4;
|
||||
for (foo = 10; foo >=0; foo = foo - 3) {
|
||||
System.out.println(foo);
|
||||
}
|
||||
}
|
||||
}
|
11
src/series/C05S03_loops/C05EX04/C05EX04c.java
Normal file
11
src/series/C05S03_loops/C05EX04/C05EX04c.java
Normal file
@ -0,0 +1,11 @@
|
||||
package series.C05S03_loops.C05EX04;
|
||||
|
||||
public class C05EX04c {
|
||||
public static void main(String[] args) {
|
||||
int foo = 10;
|
||||
while (foo>=0) {
|
||||
System.out.println(foo);
|
||||
foo -= 3;
|
||||
}
|
||||
}
|
||||
}
|
11
src/series/C05S03_loops/C05EX04/C05EX04d.java
Normal file
11
src/series/C05S03_loops/C05EX04/C05EX04d.java
Normal file
@ -0,0 +1,11 @@
|
||||
package series.C05S03_loops.C05EX04;
|
||||
|
||||
public class C05EX04d {
|
||||
public static void main(String[] args) {
|
||||
int foo = 10;
|
||||
do {
|
||||
System.out.println(foo);
|
||||
foo-=3;
|
||||
} while (foo>=0);
|
||||
}
|
||||
}
|
11
src/series/C05S03_loops/C05EX07.java
Normal file
11
src/series/C05S03_loops/C05EX07.java
Normal file
@ -0,0 +1,11 @@
|
||||
package series.C05S03_loops;
|
||||
|
||||
public class C05EX07 {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while (i<=20) {
|
||||
i++;
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
13
src/series/C05S03_loops/C05EX08/C05EX08a.java
Normal file
13
src/series/C05S03_loops/C05EX08/C05EX08a.java
Normal file
@ -0,0 +1,13 @@
|
||||
package series.C05S03_loops.C05EX08;
|
||||
|
||||
public class C05EX08a {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i <= 1000; i++) {
|
||||
sum += i;
|
||||
}
|
||||
System.out.println(sum);
|
||||
|
||||
}
|
||||
}
|
13
src/series/C05S03_loops/C05EX08/C05EX08b.java
Normal file
13
src/series/C05S03_loops/C05EX08/C05EX08b.java
Normal file
@ -0,0 +1,13 @@
|
||||
package series.C05S03_loops.C05EX08;
|
||||
|
||||
public class C05EX08b {
|
||||
public static void main(String[] args) {
|
||||
double sum = 0;
|
||||
int i;
|
||||
for (i = 0; i <= 1000; i++) {
|
||||
sum += i;
|
||||
}
|
||||
double average = sum/(i-1);
|
||||
System.out.println(average);
|
||||
}
|
||||
}
|
9
src/series/C05S03_loops/C05EX08/C05EX08c.java
Normal file
9
src/series/C05S03_loops/C05EX08/C05EX08c.java
Normal file
@ -0,0 +1,9 @@
|
||||
package series.C05S03_loops.C05EX08;
|
||||
|
||||
public class C05EX08c {
|
||||
public static void main(String[] args) {
|
||||
for (int i = 3; i < 100; i+=3) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
11
src/series/C05S03_loops/C05EX08/C05EX08d.java
Normal file
11
src/series/C05S03_loops/C05EX08/C05EX08d.java
Normal file
@ -0,0 +1,11 @@
|
||||
package series.C05S03_loops.C05EX08;
|
||||
|
||||
public class C05EX08d {
|
||||
public static void main(String[] args) {
|
||||
for (int i = -5; i <= 5; i++) {
|
||||
if (i!=0) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
src/series/C05S03_loops/C05EX08/C05EX08e.java
Normal file
14
src/series/C05S03_loops/C05EX08/C05EX08e.java
Normal file
@ -0,0 +1,14 @@
|
||||
package series.C05S03_loops.C05EX08;
|
||||
|
||||
public class C05EX08e {
|
||||
public static void main(String[] args) {
|
||||
String s = "";
|
||||
for (int i = 0; i < 6; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
s += "*";
|
||||
}
|
||||
s += "-";
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
11
src/series/C05S03_loops/C05EX08/C05EX08f.java
Normal file
11
src/series/C05S03_loops/C05EX08/C05EX08f.java
Normal file
@ -0,0 +1,11 @@
|
||||
package series.C05S03_loops.C05EX08;
|
||||
|
||||
public class C05EX08f {
|
||||
public static void main(String[] args) {
|
||||
for (int i = 333; i <= 389; i++) {
|
||||
if (i%2==0) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/series/C05S03_loops/serie3-loop.docx
Normal file
BIN
src/series/C05S03_loops/serie3-loop.docx
Normal file
Binary file not shown.
BIN
src/series/C05S03_loops/serie3-sol.pdf
Normal file
BIN
src/series/C05S03_loops/serie3-sol.pdf
Normal file
Binary file not shown.
BIN
src/series/C05S03_loops/serie3.pdf
Normal file
BIN
src/series/C05S03_loops/serie3.pdf
Normal file
Binary file not shown.
40
src/series/C06S04_fonctions/C05EX01.java
Normal file
40
src/series/C06S04_fonctions/C05EX01.java
Normal file
@ -0,0 +1,40 @@
|
||||
package series.C06S04_fonctions;
|
||||
|
||||
import hevs.utils.Input;
|
||||
|
||||
public class C05EX01 {
|
||||
|
||||
// a
|
||||
public static float cube(float x) {
|
||||
return x*x*x;
|
||||
}
|
||||
|
||||
// b
|
||||
public static double puissance(int base, int exposant) {
|
||||
double resultat = 1.0;
|
||||
for (int i = 0; i < exposant; i++) {
|
||||
resultat *= base;
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
// c
|
||||
public static void f1() {
|
||||
}
|
||||
|
||||
// d
|
||||
public static int NbrLettre(String s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// e
|
||||
public static boolean f2(int x1, int x2, String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int base = Input.readInt();
|
||||
int exposant = Input.readInt();
|
||||
System.out.println(puissance(base, exposant));
|
||||
}
|
||||
}
|
BIN
src/series/C06S04_fonctions/serie04-fonction.docx
Normal file
BIN
src/series/C06S04_fonctions/serie04-fonction.docx
Normal file
Binary file not shown.
BIN
src/series/C06S04_fonctions/serie4-sol.pdf
Normal file
BIN
src/series/C06S04_fonctions/serie4-sol.pdf
Normal file
Binary file not shown.
BIN
src/series/C06S04_fonctions/serie4.pdf
Normal file
BIN
src/series/C06S04_fonctions/serie4.pdf
Normal file
Binary file not shown.
BIN
src/series/serie1-sol.pdf
Normal file
BIN
src/series/serie1-sol.pdf
Normal file
Binary file not shown.
BIN
src/series/serie1.pdf
Normal file
BIN
src/series/serie1.pdf
Normal file
Binary file not shown.
BIN
src/series/serie2-sol.pdf
Normal file
BIN
src/series/serie2-sol.pdf
Normal file
Binary file not shown.
BIN
src/series/serie2.pdf
Normal file
BIN
src/series/serie2.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user