From f3937cc7c3661fb78edb8ae1339d92259b55c14f Mon Sep 17 00:00:00 2001 From: esoe Date: Mon, 24 Oct 2022 01:09:31 +0300 Subject: [PATCH] ready: doc and image --- files/src/main/java/ru/molokoin/Audio.java | 10 +++ .../src/main/java/ru/molokoin/Dimensions.java | 4 +- files/src/main/java/ru/molokoin/Document.java | 60 ++++++++++++++++++ .../src/main/java/ru/molokoin/Extension.java | 48 -------------- files/src/main/java/ru/molokoin/File.java | 2 +- files/src/main/java/ru/molokoin/Image.java | 35 ++++++++++ files/src/main/java/ru/molokoin/Storage.java | 39 +++++++++--- files/src/main/java/ru/molokoin/Video.java | 10 +++ files/target/classes/ru/molokoin/Audio.class | Bin 0 -> 420 bytes .../classes/ru/molokoin/Dimensions.class | Bin 739 -> 739 bytes .../target/classes/ru/molokoin/Document.class | Bin 0 -> 1751 bytes .../classes/ru/molokoin/Extension.class | Bin 2873 -> 1130 bytes files/target/classes/ru/molokoin/Image.class | Bin 0 -> 1883 bytes .../target/classes/ru/molokoin/Storage.class | Bin 1014 -> 1807 bytes files/target/classes/ru/molokoin/Video.class | Bin 0 -> 420 bytes 15 files changed, 148 insertions(+), 60 deletions(-) create mode 100644 files/src/main/java/ru/molokoin/Audio.java create mode 100644 files/src/main/java/ru/molokoin/Document.java create mode 100644 files/src/main/java/ru/molokoin/Image.java create mode 100644 files/src/main/java/ru/molokoin/Video.java create mode 100644 files/target/classes/ru/molokoin/Audio.class create mode 100644 files/target/classes/ru/molokoin/Document.class create mode 100644 files/target/classes/ru/molokoin/Image.class create mode 100644 files/target/classes/ru/molokoin/Video.class diff --git a/files/src/main/java/ru/molokoin/Audio.java b/files/src/main/java/ru/molokoin/Audio.java new file mode 100644 index 0000000..73fcff9 --- /dev/null +++ b/files/src/main/java/ru/molokoin/Audio.java @@ -0,0 +1,10 @@ +package ru.molokoin; + +public class Audio extends File{ + + public Audio(String name, byte size, Extension extension) { + super(name, size, extension); + //TODO Auto-generated constructor stub + } + +} diff --git a/files/src/main/java/ru/molokoin/Dimensions.java b/files/src/main/java/ru/molokoin/Dimensions.java index 0028f12..eb98734 100644 --- a/files/src/main/java/ru/molokoin/Dimensions.java +++ b/files/src/main/java/ru/molokoin/Dimensions.java @@ -1,8 +1,8 @@ package ru.molokoin; public class Dimensions { - int width; - int height; + private int width; + private int height; Dimensions(int width, int height){ setWidth(width); setHeight(height); diff --git a/files/src/main/java/ru/molokoin/Document.java b/files/src/main/java/ru/molokoin/Document.java new file mode 100644 index 0000000..60b1050 --- /dev/null +++ b/files/src/main/java/ru/molokoin/Document.java @@ -0,0 +1,60 @@ +package ru.molokoin; + +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 + * @param size + * @param extension + * @param format + * @param lists + */ + public Document(String name, byte 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); + } + public void print(){ + super.print(); + System.out.println("format: " + getFormat()); + System.out.println("lists: " + getLists()); + System.out.println("--------------------------------------------"); + + } + public void setFormat(String format) { + this.format = format; + } + public String getFormat() { + return format; + } + public void setLists(int lists) { + this.lists = lists; + } + public int getLists() { + return lists; + } +} diff --git a/files/src/main/java/ru/molokoin/Extension.java b/files/src/main/java/ru/molokoin/Extension.java index bf645d4..823041a 100644 --- a/files/src/main/java/ru/molokoin/Extension.java +++ b/files/src/main/java/ru/molokoin/Extension.java @@ -1,57 +1,9 @@ package ru.molokoin; -import java.sql.Time; - public enum Extension{ DOCUMENT, IMAGE, AUDIO, VIDEO, OTHER; - - private String format; - private int lists; - private Dimensions dimensions; - private String content; - private Time lenght; - - protected void initDocument(String format, int lists){ - setFormat(format); - setLists(lists); - } - protected void printDocument(){ - System.out.println("format: " + getFormat()); - System.out.println("lists: " + getLists()); - } - - protected void setFormat(String format) { - this.format = format; - } - protected void setLists(int lists) { - this.lists = lists; - } - protected void setDimensions(Dimensions dimensions) { - this.dimensions = dimensions; - } - protected void setContent(String content) { - this.content = content; - } - protected void setLenght(Time lenght) { - this.lenght = lenght; - } - protected String getFormat() { - return format; - } - protected int getLists() { - return lists; - } - protected Dimensions getDimensions() { - return dimensions; - } - protected String getContent() { - return content; - } - protected Time getLenght() { - return lenght; - } } diff --git a/files/src/main/java/ru/molokoin/File.java b/files/src/main/java/ru/molokoin/File.java index 9ab3547..7b3936b 100644 --- a/files/src/main/java/ru/molokoin/File.java +++ b/files/src/main/java/ru/molokoin/File.java @@ -2,7 +2,7 @@ package ru.molokoin; /** * Класс - обертка - * предоставляет инструментарий обращения с отдельным файлом + * */ public class File { private String name; diff --git a/files/src/main/java/ru/molokoin/Image.java b/files/src/main/java/ru/molokoin/Image.java new file mode 100644 index 0000000..851b60d --- /dev/null +++ b/files/src/main/java/ru/molokoin/Image.java @@ -0,0 +1,35 @@ +package ru.molokoin; + +public class Image extends File{ + private String format; + private Dimensions dimensions; + + public Image(String name, byte size, Extension extension, String format, Dimensions dimensions) { + super(name, size, extension); + init(format, dimensions); + } + public void print(){ + 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); + setDimensions(dimensions); + } + public void setFormat(String format) { + this.format = format; + } + public void setDimensions(Dimensions dimensions) { + this.dimensions = dimensions; + } + public String getFormat() { + return format; + } + public Dimensions getDimensions() { + return dimensions; + } + +} diff --git a/files/src/main/java/ru/molokoin/Storage.java b/files/src/main/java/ru/molokoin/Storage.java index a5cbc95..63db2d3 100644 --- a/files/src/main/java/ru/molokoin/Storage.java +++ b/files/src/main/java/ru/molokoin/Storage.java @@ -1,26 +1,47 @@ package ru.molokoin; + +import java.util.Arrays; + /** - * Класс - хранилище + * Класс - хранилище информации обо всех файлах * предоставляет инструментарий обращения с массивом файлов */ public class Storage { private File[] files; - + public Storage(){} + public Storage(File[] files){ + setFiles(files); + } public void setFiles(File[] files) { this.files = files; } public File[] getFiles() { return files; } - - + public void print(){ + int i = 0; + while (i < getFiles().length){ + getFiles()[i].print(); + i++; + } + } + public void add(File file) { + if(getFiles() == null){ + File[] result = new File[1]; + result[0] = file; + setFiles(result); + } + else{ + File[] result = Arrays.copyOf(getFiles(), getFiles().length+1); + result[result.length - 1] = file; + setFiles(result); + } + } public static void main(String[] args) { Storage storage = new Storage(); - storage.setFiles(new File[1]); - Extension e = Extension.DOCUMENT; - e.initDocument("null", 0); - storage.files[0] = new File("noname", (byte)0, e); - storage.files[0].print(); + 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.print(); } diff --git a/files/src/main/java/ru/molokoin/Video.java b/files/src/main/java/ru/molokoin/Video.java new file mode 100644 index 0000000..91042f0 --- /dev/null +++ b/files/src/main/java/ru/molokoin/Video.java @@ -0,0 +1,10 @@ +package ru.molokoin; + +public class Video extends File{ + + public Video(String name, byte size, Extension extension) { + super(name, size, extension); + //TODO Auto-generated constructor stub + } + +} diff --git a/files/target/classes/ru/molokoin/Audio.class b/files/target/classes/ru/molokoin/Audio.class new file mode 100644 index 0000000000000000000000000000000000000000..1e55fefa48d752ac3a694c9d0300dac307b6460f GIT binary patch literal 420 zcmZXPyH3L}6o&s3LX(C6QLL3sK}IFM8kM};P$1EI#)(VXA^>ZW9Blz7U~Ubqef`PO3V8)oyu%1rk34_ z%}gW{ktrMhB;Ddc<%I4Ax{??%RExA4{3nHLxq9Uq4GDGmD}`{h0s7NO2u7yNW^(n< zpjvTZxi|r_ZhIJK#k2J|8pGua_`UPv{u}%y`wjxO0l(lr4?cF->#h3Gz%EBTfju;t UV!amHRkx20y1a+5&v^$2-@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 literal 0 HcmV?d00001 diff --git a/files/target/classes/ru/molokoin/Extension.class b/files/target/classes/ru/molokoin/Extension.class index 19073a86b417a0e36365fa7a087d31e2893729c4..243596428e4e3ba8e622b7f46014d57bfc942288 100644 GIT binary patch delta 542 zcmZ{g%`yW)6opS`W_o@!A|xV-5Fv?4{DcscjiPLn1+$tbz}n9?&ybphg$J-w#blA7 zq^!MwcgPFaDYrW*R%X$2zpi`kIeniKJdc`qlZxWpJ;Tcm>NQmV%Q= zTwB3v@Tp((nm`pB!Krb}c+fLSjc7`0DVI(@!x*7)qeOSa@;iG4^J7u1jjDY8g63|ZeQNOCizHx zB1GOl(%i1UD-$1U=?==3N98DU^~bT_3^pxtZIHpGMAFQOF}H*Dcd-9;5pt9-sAG%% HS_Ioa44^|# literal 2873 zcmZ`)Xh?>fx2GXW>8^Ra|lNronrTg|T`WO14 z#TtF;Q=fkBkLuHN-x-n+k}vblo%h~z?>%>!fB*aI4S=ioMMsy0!BRC|bPMid*LLE` zXBEpS+peP{s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c811{up?>+aN_q^|W?z^#HRqNaD&tHITwg=X^X`FV`7h%*r z9b7fbCW^_y4=?+p7Tr6F+DSj?B~fyigmI9gECJlLsWD+P!)%rNihA}{tCwvaFqa)` z%k2e4Degy+C5R=PWmXh+7>DWeWWV3*#;KyQvh%w0rV~V+_#kMfCt-Z>MZBVaR|%*PD~oy8g;*w*>u5eU843bxV__-u4oRK{>Z&oEoWXIvgix3eo1rBarM>( ze!EC)3|afBG- diff --git a/files/target/classes/ru/molokoin/Video.class b/files/target/classes/ru/molokoin/Video.class new file mode 100644 index 0000000000000000000000000000000000000000..6e529bdb2b606d45e261579d9d4a831c235eb6f5 GIT binary patch literal 420 zcmZXPyH3L}6o&s3LX(Ct`&hO8!_YVMQrG+Wq4gV2tZmiJXQmH9+WExQ++ znMf0nD;xhL-SR;dg#HG)mKZTqi>w~}CxvT;df^(42u=Abg>bY1`qM}V#-_?=a`n%k zUU6Z$I03P4dl+ZMv-LQdz~u}0gY)Cz8~j)H9RzFxe!+bneC)6{SoNWWU5