From 734a5bf2f244c7c859a9b435d960c841c97c57a2 Mon Sep 17 00:00:00 2001 From: esoe Date: Mon, 24 Oct 2022 13:34:43 +0300 Subject: [PATCH] ready to use --- files/src/main/java/ru/molokoin/Audio.java | 66 +++++++++++++++++- files/src/main/java/ru/molokoin/Document.java | 31 ++------ files/src/main/java/ru/molokoin/Duration.java | 36 ++++++++++ files/src/main/java/ru/molokoin/File.java | 11 ++- files/src/main/java/ru/molokoin/Image.java | 9 ++- files/src/main/java/ru/molokoin/Storage.java | 19 ++++- files/src/main/java/ru/molokoin/Video.java | 29 ++++++-- files/target/classes/ru/molokoin/Audio.class | Bin 420 -> 1978 bytes .../target/classes/ru/molokoin/Document.class | Bin 1751 -> 1520 bytes .../target/classes/ru/molokoin/Duration.class | Bin 0 -> 1099 bytes files/target/classes/ru/molokoin/File.class | Bin 1675 -> 1690 bytes files/target/classes/ru/molokoin/Image.class | Bin 1883 -> 1883 bytes .../target/classes/ru/molokoin/Storage.class | Bin 1807 -> 2410 bytes files/target/classes/ru/molokoin/Video.class | Bin 420 -> 1624 bytes 14 files changed, 159 insertions(+), 42 deletions(-) create mode 100644 files/src/main/java/ru/molokoin/Duration.java create mode 100644 files/target/classes/ru/molokoin/Duration.class diff --git a/files/src/main/java/ru/molokoin/Audio.java b/files/src/main/java/ru/molokoin/Audio.java index 73fcff9..23c40ed 100644 --- a/files/src/main/java/ru/molokoin/Audio.java +++ b/files/src/main/java/ru/molokoin/Audio.java @@ -1,10 +1,72 @@ package ru.molokoin; +/** + * Класс, хранящий данные о аудиотреке/audio + */ public class Audio extends File{ + private String format; + private String content; + private Duration duration; - public Audio(String name, byte size, Extension extension) { + /** + * Основной конструктор файлов аудио + * @param name + * @param size + * @param extension + * @param format + * @param content + * @param duration + */ + public Audio(String name, int size, Extension extension, String format, String content, Duration duration) { super(name, size, extension); - //TODO Auto-generated constructor stub + setFormat(format); + setContent(content); + setDuration(duration); + } + + @Override + public void print() { + System.out.println("--------------------------------------------"); + super.print(); + System.out.println("format: " + getFormat()); + System.out.println("content: " + getContent()); + System.out.println("duration: " + getDuration().getSeconds() + " sec."); + } + /** + * @return the format + */ + public String getFormat() { + return format; + } + /** + * @param format the format to set + */ + public void setFormat(String format) { + this.format = format; + } + /** + * @return the content + */ + public String getContent() { + return content; + } + /** + * @param content the content to set + */ + public void setContent(String content) { + this.content = content; + } + /** + * @return the duration + */ + public Duration getDuration() { + return duration; + } + /** + * @param duration the duration to set + */ + public void setDuration(Duration duration) { + this.duration = duration; } } diff --git a/files/src/main/java/ru/molokoin/Document.java b/files/src/main/java/ru/molokoin/Document.java index 60b1050..32a1397 100644 --- a/files/src/main/java/ru/molokoin/Document.java +++ b/files/src/main/java/ru/molokoin/Document.java @@ -1,20 +1,12 @@ package ru.molokoin; +/** + * Класс, хранящий метаданные о документе/document + */ public class Document extends File{ private String format; private int lists; - /** - * Базовый конструктор класса File - * @param name - * @param size - * @param extension - */ - public Document(String name, byte size, Extension extension) { - super(name, size, extension); - //TODO Auto-generated constructor stub - } - /** * Основной конструктор документа * @param name @@ -23,27 +15,18 @@ public class Document extends File{ * @param format * @param lists */ - public Document(String name, byte size, Extension extension,String format, int lists) { + public Document(String name, int size, Extension extension,String format, int lists) { super(name, size, extension); - init(format, lists); - } - - /** - * Инициируем атрибуты документа: - * формат и количество страниц. - * @param format - * @param lists - */ - public void init(String format, int lists){ setFormat(format); setLists(lists); } + + @Override public void print(){ + System.out.println("--------------------------------------------"); super.print(); System.out.println("format: " + getFormat()); System.out.println("lists: " + getLists()); - System.out.println("--------------------------------------------"); - } public void setFormat(String format) { this.format = format; diff --git a/files/src/main/java/ru/molokoin/Duration.java b/files/src/main/java/ru/molokoin/Duration.java new file mode 100644 index 0000000..3159ca0 --- /dev/null +++ b/files/src/main/java/ru/molokoin/Duration.java @@ -0,0 +1,36 @@ +package ru.molokoin; + +/** + * Класс хранит данные о длительности (аудио/видео). + * TODO подготовить формат возвращаемого значения в виде: ХХ мин. ХХ сек. + */ +public class Duration { + private long milliseconds; + public Duration(long milliseconds){ + setMilliseconds(milliseconds); + } + public void print(){ + System.out.println(getSeconds() + "секунд."); + } + /** + * Возвращает время в секундах + * @return + */ + public long getSeconds(){ + return getMilliseconds()/1000; + } + + /** + * @param milliseconds the milliseconds to set + */ + public void setMilliseconds(long milliseconds) { + this.milliseconds = milliseconds; + } + /** + * @return the milliseconds + */ + public long getMilliseconds() { + return milliseconds; + } + +} diff --git a/files/src/main/java/ru/molokoin/File.java b/files/src/main/java/ru/molokoin/File.java index 7b3936b..5e5b9f0 100644 --- a/files/src/main/java/ru/molokoin/File.java +++ b/files/src/main/java/ru/molokoin/File.java @@ -2,27 +2,26 @@ package ru.molokoin; /** * Класс - обертка - * */ public class File { private String name; - private byte size; + private int size; private Extension extension; - public File(String name, byte size, Extension extension){ + public File(String name, int size, Extension extension){ setName(name); setSize(size); setExtension(extension); } public void print(){ System.out.println("name: " + getName()); - System.out.println("size: " + (byte) getSize()); + System.out.println("size: " + getSize() + "byte"); System.out.println("extension: " + extension); } public void setName(String name) { this.name = name; } - public void setSize(byte size) { + public void setSize(int size) { this.size = size; } public void setExtension(Extension extension) { @@ -31,7 +30,7 @@ public class File { public String getName() { return name; } - public byte getSize() { + public int getSize() { return size; } public Extension getExtension() { diff --git a/files/src/main/java/ru/molokoin/Image.java b/files/src/main/java/ru/molokoin/Image.java index 851b60d..5c5acbd 100644 --- a/files/src/main/java/ru/molokoin/Image.java +++ b/files/src/main/java/ru/molokoin/Image.java @@ -1,19 +1,22 @@ package ru.molokoin; +/** + * Класс, хранящий метаданные о изображении/image + */ public class Image extends File{ private String format; private Dimensions dimensions; - public Image(String name, byte size, Extension extension, String format, Dimensions dimensions) { + public Image(String name, int size, Extension extension, String format, Dimensions dimensions) { super(name, size, extension); init(format, dimensions); } + @Override public void print(){ + System.out.println("--------------------------------------------"); super.print(); System.out.println("format: " + getFormat()); System.out.println("Dimensions: " + getDimensions().getHeight() + " x " + getDimensions().getWidth()); - System.out.println("--------------------------------------------"); - } public void init(String format, Dimensions dimensions){ setFormat(format); diff --git a/files/src/main/java/ru/molokoin/Storage.java b/files/src/main/java/ru/molokoin/Storage.java index 63db2d3..6fd3313 100644 --- a/files/src/main/java/ru/molokoin/Storage.java +++ b/files/src/main/java/ru/molokoin/Storage.java @@ -5,6 +5,7 @@ import java.util.Arrays; /** * Класс - хранилище информации обо всех файлах * предоставляет инструментарий обращения с массивом файлов + * TODO формат вывода преобразовать в табличный вид */ public class Storage { private File[] files; @@ -25,6 +26,10 @@ public class Storage { i++; } } + /** + * Метод, добавляющий файл в хранилище/storage + * @param file + */ public void add(File file) { if(getFiles() == null){ File[] result = new File[1]; @@ -39,10 +44,18 @@ public class Storage { } public static void main(String[] args) { Storage storage = new Storage(); - storage.add(new Document("myDocument", (byte)10, Extension.DOCUMENT, "txt", 5)); - storage.add(new Image("myImage", (byte)15, Extension.IMAGE, "jpg", new Dimensions(12, 8))); + //Заполняем массив исходными данными + storage.add(new Document("myDocument", 10, Extension.DOCUMENT, "txt", 5)); + storage.add(new Image("myImage", 15, Extension.IMAGE, "jpg", new Dimensions(12, 8))); + storage.add(new Audio("myAudio", 50, Extension.AUDIO, "mp3", "some melody", new Duration(20000))); + storage.add(new Video("myVideo" + , 100500 + , Extension.VIDEO + , "mpeg" + , "some video content" + , new Duration(100500) + , new Dimensions(1024, 768))); storage.print(); - } } diff --git a/files/src/main/java/ru/molokoin/Video.java b/files/src/main/java/ru/molokoin/Video.java index 91042f0..2d47c32 100644 --- a/files/src/main/java/ru/molokoin/Video.java +++ b/files/src/main/java/ru/molokoin/Video.java @@ -1,10 +1,31 @@ package ru.molokoin; -public class Video extends File{ +/** + * Класс, хранящий метаданные о видео/video + */ +public class Video extends Audio{ + private Dimensions dimensions; - public Video(String name, byte size, Extension extension) { - super(name, size, extension); - //TODO Auto-generated constructor stub + public Video(String name, int size, Extension extension, String format, String content, Duration duration, Dimensions dimensions) { + super(name, size, extension, format, content, duration); + setDimensions(dimensions); + } + @Override + public void print() { + super.print(); + System.out.println(dimensions.getWidth() + " x " + dimensions.getHeight()); + } + /** + * @param dimensions the dimensions to set + */ + public void setDimensions(Dimensions dimensions) { + this.dimensions = dimensions; + } + /** + * @return the dimensions + */ + public Dimensions getDimensions() { + return dimensions; } } diff --git a/files/target/classes/ru/molokoin/Audio.class b/files/target/classes/ru/molokoin/Audio.class index 1e55fefa48d752ac3a694c9d0300dac307b6460f..693e7d02afc9e6434646d05879d84bd094627ee8 100644 GIT binary patch literal 1978 zcmb7^>vG#v6ouDuY)e*ETAakGP1=TXsjbv8P)ccBQra}338oZM0)^5>u|*KrQpOhs zcnY3?X8?vOGcdyg@K6kEOLAhz%8&Yob#%_Ye0%S8^zVOv{R7}SS{hOcFLnpDj^Fmb z_g$}cd(d)y4QYk5quc9l+fm4V<99oDUm@T4&i=u!wQX;&w$<;t-dyie=wP1ke#D++t%$zU5}UTZ%xY>(mUla>iPi3uy)3h7n9dLkO_R2&a(+ats(_fF9F`E!2vYs_j5Nm_ht5I_#$T<^5loU>Jd)N_$ zVtK6S;Xz%<&oo@mxj*RaI^Bo%u8bnz@SApf+wQvZ9&e`m-?}}8>9IiJMA`7PXLsnB z?zunnp*C2AGiH?+?oi40{=Vb2 zlI1k%8)MWZ#9b3>l27mZ(KXWX0kg*!N$3gMQsNsv>B*-~ z3j?S4Z}ROIq#0<*L);56nijdQ$| zMa*;eUK9oAae;4)hl|Xr!qoz)QsL?nUJ2<+AzM1!6FP}olFC9KsxhYfm2?tg=MTJ| zzY<`{I>1$~|HidP`RfO`VFjoMxD{ZPhr@&Q=-}SO!H3boM*%(w@Ol2rLxZClOJT3h zljQ>YbCDzqSRwyYTng(nBc8ZUCDM;sYkUf8#`+VFf8!zrXH4%hg+$4}E$3bo|-SP<_ nGDiX7jYqR91EbSqHYSb9{Va<43=BXn zNC}W+2ig(BzygE}3>;e8GP>ItI5q;=OblE=k_$*P0M)TGa4>KKSy~Wv3_J|HKps#B g10MrF&=e3$fI$$fnu9@zK^W)?Mg|d}I1_^?0PnyYm;e9( diff --git a/files/target/classes/ru/molokoin/Document.class b/files/target/classes/ru/molokoin/Document.class index 5193b4d097038035b1aa56569fed508013e728b5..6a946dc8c0487d6c4ae6c6ab637b2fa13d7ab379 100644 GIT binary patch literal 1520 zcmb7EYflqF6g^Y6PY2Py5P1k9&@Pn4CrYs(FD+Ii!8GyX0xPa|cS*Z7V*E*dP$MPL z#2?^~GTxcp(n9M8x=Ckd@9W%i&+MPSKYs(5$95P2hGey_Sx&`y@0hl>=Iqri!*;_^ z7_PKiHq45_5PIWOE!|~^m)_|gbgiP>2ilHXHSL2uL$G4j+!_NblINmnn{I(&In(J{ zEVZXz|L7Wa&2;R17td^&L0NV7jTm~+%Mrz8hTH{mX3H^9FC149XNcAecf;=?)g_DP zo#aR%%@85)lGl@xDGDfkCDS&x>ejANeWmXTO5!DFPp_2qswvL?OT~R_5)tV$eKyG@ zrW9MZC|0SNpJ<61O$HeH&xEw7A$AXmW}?0)lPyPa6Su+`r^edma8z>*i(>+lGucjkh_F1zA|8|E^ut5L z-tR7t&R8EtUZhy!SQhmnuH&gWf)#2=>RDi8SmRj726+%7UlKHkq6mH_>XYP$NFp5w zn^mHe<2gqVA+dYG5k`a|w&T>Rdxm$pdYb~76^vnw{Ceo32I!$MxuYOjLu83Upt?k- z&rqZ_sZI~&PQcXxrGY**6>K2!O-A+8f1JF41eHyqm(-m=8rSGe!HdNJuG0x*9hCXS zZiuP{KR&~(^LQiEJC0-!I{7?0UnXSxmU^u&cyZhVH6}~M3XvwjLlZI zm~3X0a*oLiX?YHvwjPqr(dSEO&(EdNDq0GvKd||gHUS7W#RP!yHXy-MAoS(%gIhob kk5M`gWRl8F{RfEPRum@5`MKJGl)jt;lI;p)OM1Qh2ly8t`~Uy| literal 1751 zcmb7E*-{fh6g>@DhA=>kfD1vv1;d08!36{aWm7b=2vX(a2qTUrGgLCM#BcIJEeTax zEUgG(1N>b#n6fl9c_pSbmeTvS}hmeSj8>#jZ~4yxjSZl+br60 zAG{2C?`(4S9)qs>p}3G^7ML3<*`N6k^8#&Fl~~}yv9!7(fk$W1-|Tc{csmAxOFAy2 zkL5g`>pH@S$kj_7QD_3OO}AX!vHYvpQJw8k=?H_2 zYvr|W;g@M@#Uws8p70{^x1GB!g!tuKBc03~LI0*AJNX-9CeTT$IJ&qp{5bB;aVK#S z#1(3F9^EQhLl1h%D;X{X3?B0&e>`9?E`@r+6lIW@L;jV+EU zTRdPRw(=-_#ARu?6Y_!u3O1-s)}q}=SCBN46%3ptA7aWaT23kQ0YAJ(-mc)K)piBn zLSWvW0RDgm<=LEZgrV<9{le($#O))D8x`EGV6uXl3g)T@i~hlK1QrP%`wXa;Xa1aQsUfyjG60Qm1|4xux7t(i#jgvwqNH_T(A+mLnn71pyY80~Z O<%E!_Q-y4*sI7nKPc$t6 diff --git a/files/target/classes/ru/molokoin/Duration.class b/files/target/classes/ru/molokoin/Duration.class new file mode 100644 index 0000000000000000000000000000000000000000..9d87c42e0bb27e12a05090a74cddf2ec94b16971 GIT binary patch literal 1099 zcmZuwTTc@~6#j-@wq2$ap@0gAcx|h6RaDfHifDMiDke2ed|cYG4sLgw?JkLr#^2+E z28zMx5Adn{3x9?2%yucaHtFunoO8a*nX`ZX?f(X_gjEeg3>nuqnvUgsbfj&(@LkiB zj;$feFuG-Kn}%iD4P#?-OVm6D-jtRl+oI;!^)>@rXNWILTY4piXm&kUrPp((E_6gN z%%OoZM6$W64u%nqG!hKyw(wq^fJv97EnfT0P2s*ZH!Z<1R(5KpRW)6y_TgdF`yh#Q zvOGv}ks;P{rR^m#iSrt!PUx?EYI~x|aRC=ekmHk;iE?01I>sASR`Fb6Hj5f&7^aSl z)3LN0tG=}A!c{IVam?W|gWeEc<**NAab3q1T+?v%ByUj8aUC}pv~AP!#m0N$rdIXn zgYNc7iaMr|RZYvOjI;4vHGx|Use{km-R}Oum+r6bPC*qda1>zBRhX@ou_CkVu%zK3!}x&qaXeDuwcsKwTlMP+M^W`FP5nB4>oFQZ z`bGXGDd{Ok3~_2|#qr&mSd(f7QisD>P)wMoya-h=45?&V#b~V|LC+-Z)+nmtdVY`o za~-6<(QXK%^c)EyNkpMj?l8{L*(Aj%8)F!!w^}JwnrURfL(G=}2Qd2`6F)KiF5kiI z56ti3<`^w+cW|eJ`$sf-0GYxJ5h@A=L&YHlQ-c!%FOn1$OA^fE43?W;Y17lHG=MZ5 z0VMkX^!dSZ41zR+8SE!;a4OH{ zDmaN)l?V#%`YFT@B3^pSIR0FHg%}r95rm~XktgqWt&=ChYTggyCTTm<~by2 z)Tbi{1Ea`^s|}tFKE=C(TcDo29o8Bz(Jla zHQ|w@NTd3n;7cl7-hc`j6ex1afJH~x;$F7Jv|O?}Y3vZ5NN|sED~%@!7YHwy-ow9G pN%oaQpo|HwSZ3!gg(`&X>K?TjL}n?+AIk9;Y0Fe>8QM<-2fwE7K5zg4 delta 380 zcmbQm+s(^$>ff$?3=9nB3}F+wf*749#<~KD#U+eRnrDTCpa$ucTSmlKLHoy&L1KX!C*^y0jvLu_BP{0~ADP@q9Mi4_V cP$4f+P9I2vyvGXi2f8_GK*i#$AV-G+04jYtN&o-= diff --git a/files/target/classes/ru/molokoin/Image.class b/files/target/classes/ru/molokoin/Image.class index 0bc117cf1e1cdb23499fe6af5228b4b24a2bf05e..68ee0d60e74a7b20fa6c72376fbe87e1b90d0135 100644 GIT binary patch delta 624 zcmZ9J-%b-z5XQgLrMug5thAICO@Sf>+pcy&t0+}K#7eaah<}22O{itD-8Jpj=oNQf zOXkK4d!bC@kLbVP!#ha zjA2|uT3}$O_P%B|Yj(rj_}FplEs0B*5Kx@1D=<{0s501B(lJSYlo|ChavHJ}QHFQ( zFa)%BZOe9>Hj~-vf0bNLH%hseVJNsNk-~@uQy_U3S?XHNt$JI>jDY^eX}4Xh>U3~~{ZVq% dWWUDM1RwqlI#x3@uO$?Jj~BI!n4kqM^%sGkhF|~y delta 614 zcmYjO+fEZv6kTVA&P<16wO7=%P_WeAa6l^{s9>#96t#$#V2oxG#xk{?Y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