diff --git a/src/qdev4/Ex1.java b/src/qdev4/Ex1.java new file mode 100644 index 0000000000000000000000000000000000000000..21fba00eaa5b35abeda66f5ddf5125a763d8fb06 --- /dev/null +++ b/src/qdev4/Ex1.java @@ -0,0 +1,57 @@ +package qdev4; + +public class Ex1 +{ + public void example1() throws Exception + { + doIt(); + } + public int doIt() throws Exception + { + throw new Exception(); + } + + + public void doItAgain() throws MyException { + throw new MyException(); + } + public void example3() { + try { + doItAgain(); + } catch (Exception e) { + processing(); + } + } + private void processing() { + // TODO Auto-generated method stub + } + + public int example4() { + int data = 0; + try { + data = getData(); + } catch (NullPointerException e) {e.printStackTrace();} + return data; + } + public int getData() throws NullPointerException { + throw new NullPointerException(); + } + + public void example5() { + doItFinally(); + } + public int doItFinally() { + throw new RuntimeException(); + } + + public static void main(String[] args) { + int k; + try { + k = 1/Integer.parseInt(args[0]); + } + catch(ArrayIndexOutOfBoundsException e) {System.err.println("Index " + e);} + catch(ArithmeticException e) {System.err.println("Arithmetic " + "");} + catch(RuntimeException e) {System.err.println("Runtime " + e);} + } + +} diff --git a/src/qdev4/MyException.java b/src/qdev4/MyException.java new file mode 100644 index 0000000000000000000000000000000000000000..2f97166ceb353404776194081550d659adaaa3d1 --- /dev/null +++ b/src/qdev4/MyException.java @@ -0,0 +1,11 @@ +package qdev4; + +public class MyException extends Exception { + public MyException() {} + public MyException(String msg) {super(msg);} + + public void example2() throws MyException + { + throw new MyException(); + } +} \ No newline at end of file diff --git a/src/tp08/Food.java b/src/tp08/Food.java index a5fbb7e2b71d2dc92d9df2e24fbdb86d3f048e22..accda7a8fcf8bef81ec3080d7d6267a5402bcd94 100644 --- a/src/tp08/Food.java +++ b/src/tp08/Food.java @@ -34,7 +34,7 @@ public class Food implements IProduct, Comparable<Food> public boolean isNotRotten(LocalDate aDate) { - if(this.beforeRots==aDate) + if(this.beforeRots.getDayOfYear()>=aDate.getDayOfYear() && this.beforeRots.getDayOfMonth()>=aDate.getDayOfMonth()) { return false; } diff --git a/src/tp08/Shelf.java b/src/tp08/Shelf.java index f21131e26bd3a2ba033a3ecd64471458ff817b30..e44cf358bfb049924acc1d5a343baf02ad939388 100644 --- a/src/tp08/Shelf.java +++ b/src/tp08/Shelf.java @@ -1,13 +1,12 @@ package tp08; import java.util.ArrayList; -import java.util.List; public class Shelf { private boolean refridge; private int capacityMax; - private List<IProduct> shelves; + private ArrayList<IProduct> shelves; public Shelf(boolean r, int c) { @@ -16,11 +15,16 @@ public class Shelf this.shelves = new ArrayList<>(); } - public List<IProduct> getShelves() + public ArrayList<IProduct> getShelves() { return this.shelves; } + public Food getFood(int i) + { + return (Food) getShelves().get(i); + } + public boolean add(IProduct item) { if(isFull()) diff --git a/src/tp08/Shop.java b/src/tp08/Shop.java index 7ed04a0aeba158821aecfda9eca37a3bed0b1864..540b0fefe8d53fd674e6bfc9f314f9bdc4b28a3f 100644 --- a/src/tp08/Shop.java +++ b/src/tp08/Shop.java @@ -1,27 +1,54 @@ package tp08; +import java.time.LocalDate; import java.util.ArrayList; -import java.util.List; public class Shop { - private List<Shelf> shop; + private ArrayList<Shelf> shop; public Shop() {} - public Shop(List<Shelf> s) + public Shop(ArrayList<Shelf> s) { this.shop=s; } - public List<Shelf> getShelving() + public ArrayList<Shelf> getShelving() { return this.shop; } public void tidy(ArrayList<IProduct> aStock) { - + for(int i = 0; i < shop.size(); i++) + { + for(int j = 0; j < aStock.size(); j++) + { + if(shop.get(i).isRefrigerated() && !shop.get(i).isFull() && aStock.get(i).isPerishable()) + { + shop.get(i).add(aStock.get(i)); + } + else + { + shop.get(i).add(aStock.get(i)); + } + } + } + } + + public ArrayList<Food> closeBestBeforeDate(int nbDays) + { + ArrayList<Food> funked = new ArrayList<>(); + + for(int i = 0; i < shop.size(); i++) + { + if(shop.get(i).getFood(i).isNotRotten(LocalDate.now())) + { + + } + } + return funked; } @Override diff --git a/src/tp09/LogInManagement.java b/src/tp09/LogInManagement.java new file mode 100644 index 0000000000000000000000000000000000000000..e247a4fb303d537be551e6fb3fbb4a85023534af --- /dev/null +++ b/src/tp09/LogInManagement.java @@ -0,0 +1,17 @@ +package tp09; + +public class LogInManagement +{ + public static final String LOGIN = "samuel.turpin.etu"; + public static final String PWD = "poneymagique"; + + public LogInManagement(String log, String pwd) + { + + } + + public boolean getUserPwd() + { + return true; + } +} diff --git a/src/tp09/Main.java b/src/tp09/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..19ecb9e5b0eec88e8e69a0f7fec07c9eac514933 --- /dev/null +++ b/src/tp09/Main.java @@ -0,0 +1,14 @@ +package tp09; + +import java.util.Scanner; + +public class Main +{ + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + + + + } +} \ No newline at end of file diff --git a/src/tp09/WrongLoginException.java b/src/tp09/WrongLoginException.java new file mode 100644 index 0000000000000000000000000000000000000000..7d85efc8c0f25d42da2be4d560d7ea0bcb687484 --- /dev/null +++ b/src/tp09/WrongLoginException.java @@ -0,0 +1,11 @@ +package tp09; + +public class WrongLoginException extends Exception +{ + @Override + public synchronized Throwable initCause(Throwable cause) + { + + return super.initCause(cause); + } +} \ No newline at end of file