codice:import java.io.PrintStream; /** * A class to manage files * @author Simone * */ public class MyFile { public MyFile() { /* * Non inizializza nulla. Il mio primo dubbio è proprio su questo costrut- * tore: non capisco perchè devo creare un costruttore vuoto, senza pare- * metri espliciti. Dall'altro lato, se non lo creo, tutte le sottoclassi * presentano un errore */ } /* * Costruisce un nuovo file coi parametri stabiliti nella traccia * @param type tipo file (audio, testo, immagine, video) * @param path percorso file * @param size grandezza file * @param creationData data creazione * @param lastModifiedData data ultima modifica * @param description descrizione * @param format formato */ public MyFile(String type, String path, int size, String creationData, String lastModifiedData, String description, String format) { this.type = type; this.path = path; this.size = size; this.creationData = creationData; this.lastModifiedData = lastModifiedData; this.description = description; this.format = format; } /* * da qui in avanti ci sono tutti i metodi getters e setters dei costruttori * della classe */ public String getType() { return type; } public String getPath() { return path; } public int getSize() { return size; } public String getCreationData() { return creationData; } public String getLastModifiedData() { return lastModifiedData; } public String getDescription() { return description; } public String getFormat() { return format; } public void setType(String type) { this.type = type; } public void setPath(String path) { this.path = path; } public void setSize(int size) { this.size = size; } public void setCreationData(String creationData) { this.creationData = creationData; } public void setLastModifiedData(String lastModifiedData) { this.lastModifiedData = lastModifiedData; } public void setDescription(String description) { this.description = description; } public void setFormat(String format) { this.format = format; } @Override public String toString() { return type + "\n" + path + "\n" + size + "\n" + creationData + "\n" + lastModifiedData + "\n" + description + "\n" + format; } @Override public int hashCode() { int h = 0; h = HASH_MULTIPLIER * type.hashCode() + path.hashCode(); h = HASH_MULTIPLIER * h + format.hashCode(); return h; } @Override public boolean equals(Object o) { if (o == null) return false; if (o.getClass() != this.getClass()) return false; MyFile file = (MyFile) o; return (this.type.equals(file.type) && this.path.equals(file.path) && this.format.equals(file.format)); } /** * Print on an object of PrintStream * @param p PrintStream object */ public void print(PrintStream p) { p.println(type); p.println(path); p.println(size); p.println(creationData); p.println(lastModifiedData); p.println(description); p.println(format); } private String type; private String path; private int size; private String creationData; private String lastModifiedData; private String description; private String format; private static final int HASH_MULTIPLIER = 31; }