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 MowerController
x
- 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 MowerController
abscissa
- 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 MowerController
mower
- the abscissa where the mower will bemap
- the map where to put the mowerpublic int getMowerIndex(MapArea map, Mower mower)
getMowerIndex
in interface MowerController
mower
- 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 MowerController
mower
- the mower which will execute the commandscommandLine
- the commands line (ADGB) to executeUnknownMowerCommandException
- if asked command is nullImpossibleMowerCommandException
public MapArea executeFileCommands(List<String> fileContent) throws ImpossibleMowerCommandException, MowerInstructionFileException
MowerController
executeFileCommands
in interface MowerController
fileContent
- the mower which will execute the commandUnknownMowerCommandException
- if command doesn't exists or is nullMowerInstructionFileException
- if file is bad formattedImpossibleMowerCommandException
public void executesCommands(Mower mower, char abbreviation) throws ImpossibleMowerCommandException
executesCommands
in interface MowerController
mower
- the mower which will execute the commandsabbreviation
- The abbreviation which represents the commandUnknownMowerCommandException
- if command doesn't existsImpossibleMowerCommandException
public void executesCommands(Mower mower, MowerCommands command) throws UnknownMowerCommandException
MowerController
executesCommands
in interface MowerController
mower
- the mower which will execute the commandcommand
- the command to executeUnknownMowerCommandException
- if command doesn't existspublic List<Map.Entry<Mower,MowerCommands>> getProgramHistoric()
MowerController
getProgramHistoric
in interface MowerController
public Map<MapArea,Map<Mower,String>> getMapMowersList()
MowerController
getMapMowersList
in interface MowerController
public MapArea fetchMapFromIndex(int selectedIndex)
MowerController
fetchMapFromIndex
in interface MowerController
selectedIndex
- the map's index to getpublic MapArea createMap(int x, int y)
MowerController
createMap
in interface MowerController
x
- the map's widthy
- the map's heightpublic int getMapIndex(MapArea map)
MowerController
getMapIndex
in interface MowerController
map
- the map to looks forpublic void reset()
MowerController
reset
in interface MowerController
public void removeMower(MapArea map, int abscissa, int ordinate)
MowerController
removeMower
in interface MowerController
map
- the map where to do the withdrawalabscissa
- the supposed abscissa of the mowerordinate
- the supposed ordinate of the mowerCopyright © 2016. All Rights Reserved.