update
This commit is contained in:
52
DEV.2.1/TP/TP5-Heritage/Documentation.java
Normal file
52
DEV.2.1/TP/TP5-Heritage/Documentation.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
- Dans quel package peut-on trouver la classe String ?
|
||||
La classe String se trouve dans le package java.lang.
|
||||
|
||||
- De quelle classe hérite-t-elle ?
|
||||
String hérite de la classe Object.
|
||||
|
||||
- Combien de méthodes sont transmises par la classe mère ?
|
||||
La classe Object définit 11 méthodes : clone(), equals(), finalize(), getClass(), hashCode(), notify(), notifyAll(), toString(), wait();
|
||||
|
||||
- Sur celles-ci, combien sont redéfinies ?
|
||||
Parmi ces méthodes, String redéfinit equals(), hashCode(), et toString().
|
||||
*/
|
||||
/* Écrivez un programme qui affiche tous les argument de sa ligne de commande, convertis en majuscules.
|
||||
public class AfficheMajuscules {
|
||||
public static void main(String[] args) {
|
||||
int i = 0;
|
||||
while (i < args.length) {
|
||||
System.out.println(args[i].toUpperCase());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public class OctalVersHexadecimal {
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
System.out.println("Veuillez fournir un nombre en base 8.");
|
||||
return;
|
||||
}
|
||||
|
||||
String octalString = args[0];
|
||||
|
||||
// Vérifier si l'entrée est un nombre octal valide (uniquement chiffres 0-7)
|
||||
for (int i = 0; i < octalString.length(); i++) {
|
||||
char c = octalString.charAt(i);
|
||||
if (c < '0' || c > '7') { // Si un chiffre est hors de 0-7, ce n'est pas un nombre octal
|
||||
System.out.println("Erreur : Veuillez entrer un nombre octal valide (composé uniquement de 0 à 7).");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Convertir l'octal en entier puis en hexadécimal
|
||||
int nombre = Integer.parseInt(octalString, 8);
|
||||
String hex = Integer.toHexString(nombre);
|
||||
|
||||
System.out.println("En hexadécimal : " + hex);
|
||||
}
|
||||
}
|
||||
*/
|
3
DEV.2.1/TP/TP5-Heritage/Gris.java
Normal file
3
DEV.2.1/TP/TP5-Heritage/Gris.java
Normal file
@@ -0,0 +1,3 @@
|
||||
public class Gris extends Color{
|
||||
|
||||
}
|
Reference in New Issue
Block a user