fixed facade

This commit is contained in:
2018-03-23 13:49:36 +01:00
parent 0111516595
commit c89b7f2a5e
4 changed files with 659 additions and 159 deletions

View File

@@ -9,14 +9,14 @@ import worms.util.MustNotImplementException;
/**
* Implement this interface to connect your code to the graphical user interface
* (GUI).
*
*
* <ul>
* <li>For separating the code that you wrote from the code that was provided to
* you, put <b>ALL your code in the <code>src</code> folder.</b> The code that
* is provided to you stays in the <code>src-provided</code> folder. If you
* modify the provided code, you may need to manually merge any future bugfixes
* and update.</li>
*
*
* <li>You should at least create the following classes for the code to compile:
* <ul>
* <li>a class <code>Worm</code> in the package <code>worms.model</code> for
@@ -31,48 +31,48 @@ import worms.util.MustNotImplementException;
* implements this interface (<code>IFacade</code>).</li>
* </ul>
* You may, of course, add additional classes as you see fit.
*
*
* <li>The header of that Facade class should look as follows:<br>
* <code>class Facade implements IFacade { ... }</code><br>
* Consult the <a href=
* "http://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html">
* Java tutorial</a> for more information on interfaces, if necessary.</li>
*
*
* <li>Each method defined in the interface <code>IFacade</code> must be
* implemented by the class <code>Facade</code>. For example, the implementation
* of <code>getMass</code> should call a method of the given <code>worm</code> to
* retrieve its mass.</li>
*
*
* <li>Your <code>Facade</code> class should offer a default constructor.</li>
*
*
* <li>Methods in this interface are allowed to throw only
* <code>ModelException</code>. No other exception types are allowed. This
* exception can be thrown only if (1) calling the method with the given
* parameters would violate a precondition, or (2) if the method causes an
* exception to be thrown in your code (if so, wrap the exception in a
* <code>ModelException</code>).</li>
*
*
* <li><b>ModelException should not be used anywhere outside of your Facade
* implementation.</b></li>
*
*
* <li>Your Facade implementation should <b>only contain trivial code</b> (for
* example, calling a method, combining multiple return values into an array,
* creating @Value instances, catching exceptions and wrapping it in a
* ModelException). All non-trivial code should be placed in the other classes
* that you create.</li>
*
*
* <li>The rules described above and the documentation described below for each
* method apply only to the class implementing IFacade. Your class for
* representing worms should follow the rules described in the assignment.</li>
*
*
* <li>Do not modify the signatures of the methods defined in this
* interface.</li>
*
*
* </ul>
*/
public interface IFacade {
/************
* WORLD
************/
@@ -94,28 +94,28 @@ public interface IFacade {
* pixels at the right of the terrain (i.e., largest x-coordinates).
*/
public World createWorld(double width, double height,
boolean[][] passableMap) throws ModelException;
boolean[][] passableMap) throws ModelException;
/**
* Terminate the given world.
*/
void terminate(World world) throws ModelException;
/**
* Check whether the given worls is terminated.
*/
boolean isTerminated(World world) throws ModelException;
/**
* Return the width of the given world.
*/
public double getWorldWidth(World world) throws ModelException;
/**
* Return the height of the given world.
*/
public double getWorldHeight(World world) throws ModelException;
/**
* Check whether the given world is passable at the given location.
* - The location is an array containing the x-coordinate of the location to
@@ -125,25 +125,9 @@ public interface IFacade {
boolean isPassable(World world, double[] location) throws ModelException;
/**
<<<<<<< HEAD
* Create and return a new worm that is positioned at the given location, looks
* in the given direction, has the given radius and the given name.
*
* @param location
* An array containing the x-coordinate of the position of the new
* worm followed by the y-coordinate of the position of the new worm
* (in meter)
* @param direction
* The direction of the new worm (in radians)
* @param radius
* The radius of the new worm (in meter)
* @param name
* The name of the new worm
=======
* Check whether the circular area with given center and given radius
* is passable in the given world.
* - The circular area must not lie completely within the given world.
>>>>>>> f45fa3fa96c4ea42dd782f398cf71895f06caae9
*/
boolean isPassable(World world, double[] center, double radius);
@@ -153,7 +137,7 @@ public interface IFacade {
* - The circular area must not lie completely within the given world.
*/
boolean isAdjacent(World world, double[] center, double radius);
/**
* Check whether the given world contains the given worm.
*/
@@ -163,7 +147,7 @@ public interface IFacade {
* Add the given worm to the given world.
*/
void addWorm(World world, Worm worm) throws ModelException;
/**
* Remove the given worm from the given world.
*/
@@ -173,7 +157,7 @@ public interface IFacade {
* Return a list filled with all the worms in the given world.
*/
List<Worm> getAllWorms(World world) throws ModelException;
/**
* Check whether the given world contains the given food.
*/
@@ -183,12 +167,12 @@ public interface IFacade {
* Add the given portion of food to the given world.
*/
void addFood(World world, Food food) throws ModelException;
/**
* Remove the given portion of food from the given world.
*/
void removeFood(World world, Food food) throws ModelException;
/**
* Return a collection filled with all the worms and all the
* portions of food in the given world.
@@ -199,7 +183,7 @@ public interface IFacade {
* Return a set of all the team in the given world.
*/
Set<Team> getAllTeams(World world) throws ModelException;
/**
* Check whether the given world has an active game.
*/
@@ -211,12 +195,12 @@ public interface IFacade {
* player-controlled actions.
*/
Worm getActiveWorm(World world) throws ModelException;
/**
* Start a new game in the given world.
*/
void startGame(World world) throws ModelException;
/**
* Finish the current game, if any, in the given world.
*/
@@ -237,7 +221,7 @@ public interface IFacade {
/************
* WORM
************/
/**
* Create and return a new worm that is positioned at the given location in
* the given world, that looks in the given direction, that has the given radius
@@ -249,13 +233,13 @@ public interface IFacade {
* the new worm followed by the y-coordinate of that location.
*/
Worm createWorm(World world, double[] location, double direction, double radius,
String name, Team team) throws ModelException;
String name, Team team) throws ModelException;
/**
* Terminate the given worm.
*/
void terminate(Worm worm) throws ModelException;
/**
* Check whether the given worm is terminated.
*/
@@ -326,12 +310,12 @@ public interface IFacade {
* Rename the given worm.
*/
void rename(Worm worm, String newName) throws ModelException;
/**
* Return the world to which this worm belongs
*/
World getWorld(Worm worm) throws ModelException;
/**
* Turn the given worm by the given angle.
@@ -339,7 +323,7 @@ public interface IFacade {
void turn(Worm worm, double angle);
/**
* Return the location the farthest away from its current location to which the given
* Return the location the farthest away from its current location to which the given
* worm can move in the world in which that worm is positioned, if any, following
* the given direction and not exceeding the given maximum distance.
* - The maximum distance must be finite and may not be negative.
@@ -396,12 +380,12 @@ public interface IFacade {
*/
void jump(Worm worm, double timeStep) throws ModelException;
/************
* FOOD
************/
/**
* Create and return a new portion of food that is positioned at the given
* location in the given world.
@@ -409,12 +393,12 @@ public interface IFacade {
* at the given location.
*/
Food createFood(World world, double[] location) throws ModelException;
/**
* Terminate the given portion of food.
*/
void terminate(Food food) throws ModelException;
/**
* Check whether the given portion of food is terminated.
*/
@@ -440,10 +424,10 @@ public interface IFacade {
/**
* Return the world to which this portion of food belongs.
*/
World getWorld(Food food) throws ModelException;
World getWorld(Food food) throws ModelException;
/********
* TEAM
********/
@@ -456,21 +440,21 @@ public interface IFacade {
throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
}
/**
* Terminate the given team.
*/
default void terminate(Team team) throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
}
/**
* Check whether the given portion of food is terminated.
*/
default boolean isTerminated(Team team) throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
}
/**
* Return the name of the given team.
* - Students working alone on the project must not override this method.
@@ -478,7 +462,7 @@ public interface IFacade {
default String getName(Team team) throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
}
/**
* Return the team to which this worm belongs.
@@ -487,7 +471,7 @@ public interface IFacade {
default Team getTeam(Worm worm) throws ModelException {
throw new MustNotImplementException();
}
/**
* Return the number of worms in the given team.
* - Students working alone on the project must not override this method.
@@ -496,7 +480,7 @@ public interface IFacade {
throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
}
/**
* Return a list of all the worms in the given team, sorted alphabetically.
* This method must run in linear time.
@@ -506,7 +490,7 @@ public interface IFacade {
throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
};
/**
* Add the given worms to the given team.
* - Students working alone on the project must not override this method.
@@ -515,7 +499,7 @@ public interface IFacade {
throws ModelException, MustNotImplementException {
throw new MustNotImplementException();
}
/**
* Remove the given worms from the given team.
* - Students working alone on the project must not override this method.
@@ -535,5 +519,5 @@ public interface IFacade {
throw new MustNotImplementException();
}
}
}