Skip to content

Commit 80c9c73

Browse files
Added documentation to code
1 parent a20b474 commit 80c9c73

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/src/interpreter.dart

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ class CATInterpreter {
121121
}
122122
}
123123

124+
/// It takes a string, checks if it is a valid cell, and if it is,
125+
/// it calls the move function of the command caller with the string and
126+
/// a list of integers
124127
void goCell(String cell) {
125128
bool call = true;
126129
if (cell.length == 2 &&
@@ -143,6 +146,9 @@ class CATInterpreter {
143146
_error = CatError.none;
144147
}
145148

149+
/// It takes a string and an integer, checks if the string is a valid move,
150+
/// and if it is, it calls the move function of the command caller with the
151+
/// string and a list of integers
146152
void go(String move, int repetitions) {
147153
final bool call = _commandCaller.move(move, <int>[repetitions]);
148154
if (!call) {
@@ -167,12 +173,15 @@ class CATInterpreter {
167173
}
168174
if (command.last.startsWith("{") && command.last.endsWith("}")) {
169175
final List<String> destinations = splitByCurly(command.last);
170-
paintMultileCells(colors, destinations);
176+
paintMultipleCells(colors, destinations);
171177
} else {
172178
paintPattern(colors, command[1], command[2]);
173179
}
174180
}
175181

182+
/// It takes a string, checks if it is a valid color, and if it is,
183+
/// it calls the color function of the command caller with the string and
184+
/// a list of integers with the current position of the board
176185
void paintPattern(List<String> colors, String repetitions, String pattern) {
177186
final List<int> colorsParsed =
178187
colors.map((String e) => containsColor(e.trim()).index).toList();
@@ -208,7 +217,10 @@ class CATInterpreter {
208217
_commandCaller.board.move.toPosition(row, column);
209218
}
210219

211-
void paintMultileCells(List<String> colors, List<String> cellsPositions) {
220+
/// It takes a string, checks if it is a valid color, and if it is,
221+
/// it calls the color function of the command caller with the string and
222+
/// a list of integers with the current position of the board
223+
void paintMultipleCells(List<String> colors, List<String> cellsPositions) {
212224
final List<int> colorsParsed =
213225
colors.map((String e) => containsColor(e.trim()).index).toList();
214226
if (colorsParsed.contains(CatColors.NaC.index) || colors.isEmpty) {
@@ -235,6 +247,9 @@ class CATInterpreter {
235247
_commandCaller.board.move.toPosition(row, column);
236248
}
237249

250+
/// It takes a string, checks if it is a valid color, and if it is,
251+
/// it calls the color function of the command caller with the string and
252+
/// a list of integers with the current position of the board
238253
void paintSingleCell(String color) {
239254
final int colorParsed = containsColor(color.trim()).index;
240255
if (colorParsed == CatColors.NaC.index) {

0 commit comments

Comments
 (0)