Facebook
From Sexy Owl, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 222
  1. import java.time.LocalDate;
  2.  
  3. public class PlikVideo extends Plik{
  4.  
  5.     public PlikVideo(String nazwa , int rozmiar, boolean czyDoZapisu, String rozszerzenie){
  6.         super(nazwa, rozmiar, czyDoZapisu);
  7.         this.rozszerzenie = rozszerzenie;
  8.         this.dataUtworzenia = LocalDate.now();
  9.     }
  10.  
  11.     public boolean equals(Object obj) {
  12.         if(super.equals(obj) == true){
  13.             PlikVideo other = (PlikVideo) obj;
  14.             if (rozszerzenie == null) if (other.rozszerzenie != null) return false;
  15.             else if (!rozszerzenie.equals(other.rozszerzenie)) return false;
  16.             if(!this.dataUtworzenia.equals(other.dataUtworzenia)) return false;
  17.         } else return false;
  18.         return true;
  19.     }
  20.  
  21.     public int compareTo(Plik other)
  22.     {
  23.         PlikVideo otherP = (PlikVideo) other;
  24.         if(super.compareTo(otherP) == 0){
  25.             if((this.dataUtworzenia.compareTo(otherP.dataUtworzenia)) == 0){
  26.                 return 0;
  27.             } else return this.dataUtworzenia.compareTo(otherP.dataUtworzenia);
  28.         } else return super.compareTo(otherP);
  29.     }
  30.  
  31.     public Object clone() throws CloneNotSupportedException {
  32.         return super.clone();
  33.     }
  34.  
  35.     public String toString(){
  36.         return super.toString() + " , " + "[" + this.dataUtworzenia + "]" + " , Dzień tygodnia w którym został wyprodukowany: " +
  37.                 "[" + this.dataUtworzenia.getDayOfWeek().name() + "]" + " , Dzień roku w krórym został wyprodukowany: " + this.dataUtworzenia.getDayOfYear();
  38.     }
  39.  
  40.     public void setDataUtworzenia(int rok, int miesiac, int dzien){
  41.         this.dataUtworzenia = LocalDate.of(rok,miesiac,dzien);
  42.     }
  43.  
  44.     public LocalDate getDataUtworzenia(){
  45.         return this.dataUtworzenia;
  46.     }
  47.  
  48.     private String rozszerzenie;
  49.     private LocalDate dataUtworzenia;
  50.  
  51. }