diff --git a/src/tp5/Book.java b/src/tp5/Book.java new file mode 100644 index 0000000000000000000000000000000000000000..f75daa7502cdf3c313de86ce2dcb3597db853557 --- /dev/null +++ b/src/tp5/Book.java @@ -0,0 +1,71 @@ +package tp5; + +public class Book { + + //attributs + private String code; + private final String TITLE; + private /*final*/ String author; + private final int PUBLICATIONYEAR; + + //constructeurs + public Book(String code, String title, String author, int publicationYear){ + this.code = code; + this.TITLE = title; + this.author = author; + this.PUBLICATIONYEAR = publicationYear; + } + + + + + //getters + + public String getCode() { + return code; + } + + public String getTITLE() { + return TITLE; + } + + public String getAuthor() { + return author; + } + + public int getPUBLICATIONYEAR() { + return PUBLICATIONYEAR; + } + + //sept heure + + public void setCode(String code) { + this.code = code; + } + + public void setAuthor(String author) { + this.author = author; + } + + //méthodes + + public String toString(){ + return this.code.toUpperCase() + ":" + this.TITLE + "->" + this.author + "," + this.PUBLICATIONYEAR; + } + + public boolean equals(Object other){ + if(this==other)return true; + if(this==null) return false; + //classe + if(this.getClass()!=other.getClass()){return false;} + Book autreNomQueOther = (Book) other; + //primitifs + if(this.PUBLICATIONYEAR != autreNomQueOther.PUBLICATIONYEAR) return false; + //objets + if(this.author==null) {if(autreNomQueOther.author != null) return false;} + else if(!this.author.equals(autreNomQueOther.author))return false; + } + + + +} diff --git a/src/tp5/Library.java b/src/tp5/Library.java new file mode 100644 index 0000000000000000000000000000000000000000..c311b936a5f81bb1766eaad6b5701457e77c773b --- /dev/null +++ b/src/tp5/Library.java @@ -0,0 +1,42 @@ +package tp5; + +import java.util.ArrayList; + +//shift alt O + +public class Library { + + private ArrayList<Book> catalog; + + public Library(){ + this.catalog=new ArrayList<Book>(); + } + + public void useLibrary(){ + if(catalog.isEmpty()){ + + }else{ + + } + } + + public Book getBook(String code){ + Book res = null; + for(int i=0;i<catalog.size();i++) + if(code.equals(catalog.get(i).getCode())){ + res = catalog.get(i); + return res; + } + return null; + } + + boolean addBook(Book b){ + for(int i=0;i<catalog.size();i++) + if(equals(b,catalog.get(i),b)){ + add(b); + return true; + } + return false; + } + +} diff --git a/src/tp6/Company.java b/src/tp6/Company.java new file mode 100644 index 0000000000000000000000000000000000000000..b45d57f1abc6b840e86443296d8c9199aaecea05 --- /dev/null +++ b/src/tp6/Company.java @@ -0,0 +1,7 @@ +package tp6; + +import java.util.ArrayList; + +public class Company { + private ArrayList<Employee> staff = new ArrayList<>(); +}