How do I use an Interface for this?
Hi all, if someone could explain the logic behind this I'd appreciate it.:)
I have to construct a UML to model a "World Builder" for a basic adventure game.
The model I have so far has entities/classes: World, Site, Player, Item, GridReference, ExitPoint etc....
Each class forms a relationship with other classes in the system/model. To unify the classes I have created a class "WorldBuilderEngine" which brings all "high-level" operations into one area to ease the development of a GUI, which I will do at a later date. The problem specs also state:
"Note that it is advisable to expose the system functionality via an interface, therefore you should also provide a facade interface e.g. WorldBuilderModel. Your WorldBuilderEngine class can then implement this interface."
From this I gather that the code will look something like this:
-----
public interface WorldBuilderModel {
public void addSite(...) throws StructuralException;
...
// other required methods
...
}
-----
public class WorldBuilderEngine implements WorldBuilderModel {
public void addSite(...) throws StructuralException
{
...
}
...
// implement other methods exposed in the WorldBuilderModel interface
...
}
But what I don't understand is how is using an interface going prevent system exposure?
If the interface is esentially a copy of the class that implements it, how will that be usable as the means to access the system?
My understanding of an interface, is that it provides functionallity for classes that are otherwise not related so that certain operations can be used in a polymorphic manner. This is because java does not allow multiple inheriatnce.
I have many classes that are all used in some manner to give the required output and provide the desired functionallity. These operationis are all combined into the "WorldBuilderEngine"
If someone could explain to me how I am supposed to do this using the WorldBuilderModel interface I would be greatfull.
For the first part of thid problem I am only required to Model the system using UML, so if someone is able to help, could you please take that into consideration when explaining it to me.:)