I am new to Java and trying to solve some issues where I need to convert a UML diagram to Java code: I have an image of an uml document -
http://s1079.photobucket.com/albums/w513/user20121/?action=view¤t=uml.jpg
I will show you what I still have:
Q1: Write the Java version of the Entry class, assuming it has this constructor: public Entry (String name) and the getSize method is abstract. AND:
public abstract class Entry {
private String name;
public Entry(String name){
this.name = name;
}
public String getName()
{
return name;
}
abstract long getSize();
}
Q2: write the Java version of the File class, assuming that it has this constructor: public File (String name, long size) A:
public class File extends Entry {
private long size;
public File(String name, long size){
super(name);
this.size = size;
}
public long getSize(){
return size;
}
}
Q3: . Java- Directory, , :
public Directory (String name), getSize
( ).
A: , , getSize. - , ? Q3?
: , , .
import java.util.ArrayList;
public class Directory extends Entry {
ArrayList <Entry> entries = new ArrayList<Entry>();
public Directory(String name)
{
super(name);
}
public long getSize(){
long size;
for(int i=0;i<entries.size();i++)
{
size +=
}
return size;
}
}