Advertisement
Hydron

Clip.java(for first lab)

Feb 19th, 2022
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package ua.lviv;
  2.  
  3. import java.util.Date;
  4.  
  5. public record Clip(String creatorsName, String songName, String tags, int duration, int numberOfViews, double sizeInBm, Date dateOfCreation){
  6.  
  7.     private static String resource = "Youtube";
  8.  
  9.     public static void setResource(String _resource) {
  10.         resource = _resource;
  11.     }
  12.     public static String getResource(){
  13.         return resource;
  14.     }
  15.  
  16.     public Clip() {
  17.         this("Pasha", "GimnUkrainy", "#the_best_song_of_all_time#download_and_listen_every_day",  73, 4000000, 31, new Date());
  18.         System.out.print("Constructor of zero parameters was called\n");
  19.     }
  20.     public Clip(String creatorsName, String songName, String tags) {
  21.         this(creatorsName, songName, tags,  73, 4000000, 31, new Date());
  22.         System.out.print("Constructor of three parameters was called\n");
  23.     }
  24.  
  25.     @Override
  26.     public String toString(){
  27.         String returnValue = "'" + songName + "' by " + creatorsName + " was viewed " + numberOfViews + " times. Tags: ";
  28.         if (tags.length() > 0) {
  29.             returnValue += tags.charAt(0);
  30.             for (int i=1; i<tags.length(); i++) {
  31.                 if (tags.charAt(i) == '#') returnValue += ", ";
  32.                 returnValue += tags.charAt(i);
  33.             }
  34.         }
  35.         returnValue += '\n';
  36.         return  returnValue;
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement