public class Plik implements Cloneable, Comparable{ public Plik(String nazwa, int rozmiar, boolean czyDoZapisu){ this.nazwa = nazwa; this.rozmiar = rozmiar; this.czyDoZapisu = czyDoZapisu; ile++; } public Plik(int rozmiar, boolean czyDoZapisu){ this("Jakis Plik", rozmiar, czyDoZapisu); } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Plik other = (Plik) obj; if (nazwa == null) if (other.nazwa != null) return false; else if (!nazwa.equals(other.nazwa)) return false; if (this.rozmiar != other.rozmiar) return false; if (this.czyDoZapisu != other.czyDoZapisu) return false; if (this.ile != other.ile) return false; return true; } public int compareTo(Plik other) { if((this.nazwa.compareTo(other.nazwa)) == 0){ if(this.rozmiar == other.rozmiar) { if(this.czyDoZapisu == other.czyDoZapisu){ if(this.ile == other.ile){ return 0; } else if (this.ile > other.ile) return 1; else return -1; } else return 1; } else if(this.rozmiar > other.rozmiar) return 1; else return -1; }else return this.nazwa.compareTo(other.nazwa); } public Object clone() throws CloneNotSupportedException { return super.clone(); } public String toString(){ if(nazwa == "Jakis Plik"){ return this.getClass().getSimpleName() + " [" + this.rozmiar + "]" + " , " + "[" + this.czyDoZapisu + "]" + " , " + "[" + this.ile + "]"; } return this.getClass().getSimpleName() + " [" + this.nazwa + "]" + " , " + "[" + this.rozmiar + "]" + " , " + "[" + this.czyDoZapisu + "]" + " , " + "[" + this.ile + "]"; } public void setNazwa(String nazwa){ this.nazwa = nazwa; } public void setRozmiar(int rozmiar){ this.rozmiar = rozmiar; } public void setCzyDoZapisu(boolean czyDoZapisu){ this.czyDoZapisu = czyDoZapisu; } public void setIle(int ile){ this.ile = ile; } public String getNazwa(){ return this.nazwa; } public int getRozmiar(){ return this.rozmiar; } public boolean getCzyDoZapisu(){ return this.czyDoZapisu; } public static int getIle(){ return ile; } private String nazwa; private int rozmiar; private boolean czyDoZapisu; public static int ile = 0; }