Skip to content
Snippets Groups Projects
Commit 8edbf7e8 authored by Baptiste Royer's avatar Baptiste Royer
Browse files

Ajout des exemples du premier exercice du TP04 de

dev
parent 0c961888
No related branches found
No related tags found
No related merge requests found
package TP04.Exemple1;
public class Exemple1 {
public void example1() throws Exception {
doIt();
}
public int doIt() throws Exception {
throw new Exception();
}
}
\ No newline at end of file
package TP04.Exemple2;
public class Dutilisation {
public void example2() throws MyException {
throw new MyException();
}
}
\ No newline at end of file
package TP04.Exemple2;
public class MyException extends Exception {
public MyException() {}
public MyException(String message) {super(message);}
}
\ No newline at end of file
package TP04.Exemple3;
import TP04.Exemple2.MyException;
public class Exemple3 {
public void doItAgain() throws MyException {
throw new MyException();
}
public void example3() {
try {
doItAgain();
} catch (Exception e) {
//processing(); //N'existe pas ta grand mère la cheffe cuistot.
}
}
}
\ No newline at end of file
package TP04.Exemple4;
public class Exemple4 {
public int example4() {
int data = 0; // Initialize the variable with a default value
try {
data = getData();
} catch (NullPointerException e) {
e.printStackTrace();
}
return data;
}
public int getData() throws NullPointerException {
throw new NullPointerException();
}
}
package TP04.Exemple5;
public class Exemple5 {
public void example5() {
doItFinally();
}
public int doItFinally() {
throw new RuntimeException();
}
}
/*
* Aucune erreur ici va savoir pourquoi...
*/
\ No newline at end of file
package TP04.Exemple6;
public class Exemple6 {
public static void main(String[] args) {
int k;
try {
k = 1/Integer.parseInt(args[0]);
} catch(RuntimeException e) {
System.err.println("Runtime " + e);
}
k = 0; //Pour éviter les erreurs après.
System.out.println(k); //Sinon c'est en orange et c'est pas beau.
}
}
/*
* Il suffit de tout retirer parce que c'est complètement con de le garder.
*/
\ No newline at end of file
class Book {
// class attributes
String author;
......
package tp04;
import tpOO.tp04.PendingCase;
public class UsePendingCaseQueue {
public static void main(String[] args) {
PendingCase pc1 = new PendingCase("Alice", "AAA", 1234.56);
......
package tpOO.tp05;
package tp05;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment