Skip to content
Snippets Groups Projects
Commit a02405a0 authored by Samuel Turpin's avatar Samuel Turpin :computer:
Browse files

qdevici

parent f15c086b
No related branches found
No related tags found
No related merge requests found
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);}
}
}
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
......@@ -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;
}
......
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())
......
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
......
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;
}
}
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
package tp09;
public class WrongLoginException extends Exception
{
@Override
public synchronized Throwable initCause(Throwable cause)
{
return super.initCause(cause);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment