Browse Source

ready: doc and image

master
esoe 2 years ago
parent
commit
f3937cc7c3
  1. 10
      files/src/main/java/ru/molokoin/Audio.java
  2. 4
      files/src/main/java/ru/molokoin/Dimensions.java
  3. 60
      files/src/main/java/ru/molokoin/Document.java
  4. 48
      files/src/main/java/ru/molokoin/Extension.java
  5. 2
      files/src/main/java/ru/molokoin/File.java
  6. 35
      files/src/main/java/ru/molokoin/Image.java
  7. 39
      files/src/main/java/ru/molokoin/Storage.java
  8. 10
      files/src/main/java/ru/molokoin/Video.java
  9. BIN
      files/target/classes/ru/molokoin/Audio.class
  10. BIN
      files/target/classes/ru/molokoin/Dimensions.class
  11. BIN
      files/target/classes/ru/molokoin/Document.class
  12. BIN
      files/target/classes/ru/molokoin/Extension.class
  13. BIN
      files/target/classes/ru/molokoin/Image.class
  14. BIN
      files/target/classes/ru/molokoin/Storage.class
  15. BIN
      files/target/classes/ru/molokoin/Video.class

10
files/src/main/java/ru/molokoin/Audio.java

@ -0,0 +1,10 @@ @@ -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
}
}

4
files/src/main/java/ru/molokoin/Dimensions.java

@ -1,8 +1,8 @@ @@ -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);

60
files/src/main/java/ru/molokoin/Document.java

@ -0,0 +1,60 @@ @@ -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;
}
}

48
files/src/main/java/ru/molokoin/Extension.java

@ -1,57 +1,9 @@ @@ -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;
}
}

2
files/src/main/java/ru/molokoin/File.java

@ -2,7 +2,7 @@ package ru.molokoin; @@ -2,7 +2,7 @@ package ru.molokoin;
/**
* Класс - обертка
* предоставляет инструментарий обращения с отдельным файлом
*
*/
public class File {
private String name;

35
files/src/main/java/ru/molokoin/Image.java

@ -0,0 +1,35 @@ @@ -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;
}
}

39
files/src/main/java/ru/molokoin/Storage.java

@ -1,26 +1,47 @@ @@ -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();
}

10
files/src/main/java/ru/molokoin/Video.java

@ -0,0 +1,10 @@ @@ -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
}
}

BIN
files/target/classes/ru/molokoin/Audio.class

Binary file not shown.

BIN
files/target/classes/ru/molokoin/Dimensions.class

Binary file not shown.

BIN
files/target/classes/ru/molokoin/Document.class

Binary file not shown.

BIN
files/target/classes/ru/molokoin/Extension.class

Binary file not shown.

BIN
files/target/classes/ru/molokoin/Image.class

Binary file not shown.

BIN
files/target/classes/ru/molokoin/Storage.class

Binary file not shown.

BIN
files/target/classes/ru/molokoin/Video.class

Binary file not shown.
Loading…
Cancel
Save