public class MainController extends Object implements MowerController
| Constructor and Description |
|---|
MainController(FileControlInterface fileControl,
LanguageManagerInterface languageManager)
Basic private constructor, instantiation a new Hashmap which will contains mowers data.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMower(MapArea map,
int abscissa,
int ordinate)
create a new mower at the cordinates provided.
|
void |
addMower(MapArea map,
Mower mower)
add a new mower.
|
MapArea |
createMap(int x,
int y)
Create a new empty map and add it to the mowerMapsList.
|
MapArea |
executeFileCommands(List<String> fileContent)
Create a new map, its mowers and their commands and execute it all.
|
void |
executesCommands(Mower mower,
char abbreviation)
Make the mower to execute one command.
|
void |
executesCommands(Mower mower,
MowerCommands command)
Make the mower executes the command.
|
void |
executesCommands(Mower mower,
String commandLine)
Parse the commandLine, will extract each command one by one and will make the mower to execute it.
|
MapArea |
fetchMapFromIndex(int selectedIndex)
Get the map located at the provided index.
|
Mower |
fetchMowerFromCoordinates(MapArea map,
int x,
int y)
Will check the mower's state and will return the mower located at the 'x','y' position.
|
int |
getMapIndex(MapArea map)
Get the map index.
|
Map<MapArea,Map<Mower,String>> |
getMapMowersList()
Get the complete list of the Map and the mowers and their commands line.
|
int |
getMowerIndex(MapArea map,
Mower mower)
will check the mower's position in the map.
|
List<Map.Entry<Mower,MowerCommands>> |
getProgramHistoric()
Get the full historic of the program.
|
MapArea |
init(int x,
int y)
initialize the map.
|
void |
removeMower(MapArea map,
int abscissa,
int ordinate)
Remove the mower from the map.
|
void |
reset()
Empty all the data.
|
void |
setMapMowersList(Map<MapArea,Map<Mower,String>> mapMowersList) |
@Inject public MainController(FileControlInterface fileControl, LanguageManagerInterface languageManager)
fileControl - the File controller used to load and executes file.languageManager - language manager used for internationalizationpublic MapArea init(int x, int y)
x - the map widthy - the map heightpublic Mower fetchMowerFromCoordinates(MapArea map, int x, int y)
fetchMowerFromCoordinates in interface MowerControllerx - the abscissa where the mower is supposed to bey - the ordinate where the mower is supposed to bemap - the map where to find the mowerpublic void addMower(MapArea map, int abscissa, int ordinate)
addMower in interface MowerControllerabscissa - the abscissa where the mower will beordinate - the ordinate where the mower will bemap - the map where to put the mowerpublic void addMower(MapArea map, Mower mower)
addMower in interface MowerControllermower - the abscissa where the mower will bemap - the map where to put the mowerpublic int getMowerIndex(MapArea map, Mower mower)
getMowerIndex in interface MowerControllermower - the mower to findmap - the map where the mower is supposed to be.public final void executesCommands(Mower mower, String commandLine) throws ImpossibleMowerCommandException
executesCommands in interface MowerControllermower - the mower which will execute the commandscommandLine - the commands line (ADGB) to executeUnknownMowerCommandException - if asked command is nullImpossibleMowerCommandExceptionpublic MapArea executeFileCommands(List<String> fileContent) throws ImpossibleMowerCommandException, MowerInstructionFileException
MowerControllerexecuteFileCommands in interface MowerControllerfileContent - the mower which will execute the commandUnknownMowerCommandException - if command doesn't exists or is nullMowerInstructionFileException - if file is bad formattedImpossibleMowerCommandExceptionpublic void executesCommands(Mower mower, char abbreviation) throws ImpossibleMowerCommandException
executesCommands in interface MowerControllermower - the mower which will execute the commandsabbreviation - The abbreviation which represents the commandUnknownMowerCommandException - if command doesn't existsImpossibleMowerCommandExceptionpublic void executesCommands(Mower mower, MowerCommands command) throws UnknownMowerCommandException
MowerControllerexecutesCommands in interface MowerControllermower - the mower which will execute the commandcommand - the command to executeUnknownMowerCommandException - if command doesn't existspublic List<Map.Entry<Mower,MowerCommands>> getProgramHistoric()
MowerControllergetProgramHistoric in interface MowerControllerpublic Map<MapArea,Map<Mower,String>> getMapMowersList()
MowerControllergetMapMowersList in interface MowerControllerpublic MapArea fetchMapFromIndex(int selectedIndex)
MowerControllerfetchMapFromIndex in interface MowerControllerselectedIndex - the map's index to getpublic MapArea createMap(int x, int y)
MowerControllercreateMap in interface MowerControllerx - the map's widthy - the map's heightpublic int getMapIndex(MapArea map)
MowerControllergetMapIndex in interface MowerControllermap - the map to looks forpublic void reset()
MowerControllerreset in interface MowerControllerpublic void removeMower(MapArea map, int abscissa, int ordinate)
MowerControllerremoveMower in interface MowerControllermap - the map where to do the withdrawalabscissa - the supposed abscissa of the mowerordinate - the supposed ordinate of the mowerCopyright © 2016. All Rights Reserved.