diff --git a/LAB5.drawio b/LAB5.drawio new file mode 100644 index 0000000..eaa1ce2 --- /dev/null +++ b/LAB5.drawio @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UML.png b/UML.png new file mode 100644 index 0000000..9ea856a Binary files /dev/null and b/UML.png differ diff --git a/app/.classpath b/app/.classpath index 961b063..be88c88 100644 --- a/app/.classpath +++ b/app/.classpath @@ -12,13 +12,6 @@ - - - - - - - diff --git a/app/src/main/java/itmo/lab5/cli/commands/ClearCommand.java b/app/src/main/java/itmo/lab5/cli/commands/ClearCommand.java index 7c132bb..8d1fa55 100644 --- a/app/src/main/java/itmo/lab5/cli/commands/ClearCommand.java +++ b/app/src/main/java/itmo/lab5/cli/commands/ClearCommand.java @@ -10,18 +10,19 @@ import itmo.lab5.models.Flat; * This class implements the Command interface and provides * functionality to clear the collection of Flat objects. * - * When executed, this command retrieves the collection from the command context + * When executed, this command retrieves the collection from the command context * and removes all items from it, effectively emptying the collection. */ public class ClearCommand implements Command { - + /** - * Executes the clear command, removing all items from the collection + * Executes the clear command, removing all items from the collection * of flats. * - * @param args an array of arguments passed to the command + * @param args an array of arguments passed to the command * @param context the command context that contains the collection of flats - * @return a message indicating the result of the operation, or an error message if the collection cannot be parsed + * @return a message indicating the result of the operation, or an error message + * if the collection cannot be parsed */ @Override public String execute(String args[], CommandContext context) { diff --git a/app/src/main/java/itmo/lab5/cli/commands/ExitCommand.java b/app/src/main/java/itmo/lab5/cli/commands/ExitCommand.java index b65b77e..284c8de 100644 --- a/app/src/main/java/itmo/lab5/cli/commands/ExitCommand.java +++ b/app/src/main/java/itmo/lab5/cli/commands/ExitCommand.java @@ -10,11 +10,11 @@ import itmo.lab5.interfaces.Command; * When called, main loop will immediately stop. */ public class ExitCommand implements Command { - + /** * Executes the exit command, terminating the application. * - * @param args an array of arguments passed to the command + * @param args an array of arguments passed to the command * @param context the command context that may contain additional data * @return an empty string */ @@ -23,4 +23,4 @@ public class ExitCommand implements Command { System.exit(0); return ""; } -} \ No newline at end of file +} diff --git a/app/src/main/java/itmo/lab5/cli/commands/HelpCommand.java b/app/src/main/java/itmo/lab5/cli/commands/HelpCommand.java index 0b9fb6e..e0b2bc6 100644 --- a/app/src/main/java/itmo/lab5/cli/commands/HelpCommand.java +++ b/app/src/main/java/itmo/lab5/cli/commands/HelpCommand.java @@ -8,18 +8,19 @@ import itmo.lab5.interfaces.Command; * This class implements the Command interface and provides * functionality to display a list of available commands in the application. * - * When executed, this command retrieves the command registry from the context - * and constructs a string that lists all registered commands. + * When executed, this command retrieves the command registry from the context + * and constructs a string that lists all registered commands. * If no commands are available, it informs user. */ public class HelpCommand implements Command { - + /** * Executes the help command, returning a list of available commands. * - * @param args an array of arguments passed to the command + * @param args an array of arguments passed to the command * @param context the command context that contains the command registry - * @return a string listing all available commands, or a message indicating that no commands are available + * @return a string listing all available commands, or a message indicating that + * no commands are available */ @Override public String execute(String args[], CommandContext context) { @@ -32,12 +33,11 @@ public class HelpCommand implements Command { } result.append("List of available commands: "); - registry.getAllCommands().keySet().forEach(command -> - result.append(command).append(", ")); + registry.getAllCommands().keySet().forEach(command -> result.append(command).append(", ")); return result - .delete(result.length() - 2, result.length()) - .append(".") - .toString(); + .delete(result.length() - 2, result.length()) + .append(".") + .toString(); } } diff --git a/app/src/main/java/itmo/lab5/cli/commands/RemoveKeyCommand.java b/app/src/main/java/itmo/lab5/cli/commands/RemoveKeyCommand.java index 0b01cd0..73d9e80 100644 --- a/app/src/main/java/itmo/lab5/cli/commands/RemoveKeyCommand.java +++ b/app/src/main/java/itmo/lab5/cli/commands/RemoveKeyCommand.java @@ -10,19 +10,21 @@ import itmo.lab5.models.Flat; * This class implements the Command interface and provides * functionality to remove a object from the collection based on its ID. * - * When executed, this command retrieves the collection from the command - * context, checks for the specified ID in the arguments, and removes + * When executed, this command retrieves the collection from the command + * context, checks for the specified ID in the arguments, and removes * the corresponding object if it exists. If the ID is invalid * or the collection is empty, appropriate error messages are returned. */ public class RemoveKeyCommand implements Command { - + /** * Executes the remove key command, deleting a flat by ID. * - * @param args an array of arguments passed to the command, where the first element is expected to be the ID of the flat to remove + * @param args an array of arguments passed to the command, where the first + * element is expected to be the ID of the flat to remove * @param context the command context that contains the collection of flats - * @return a message indicating the result of the operation, or an error message if the collection cannot be parsed or the ID is invalid + * @return a message indicating the result of the operation, or an error message + * if the collection cannot be parsed or the ID is invalid */ @Override public String execute(String args[], CommandContext context) { @@ -53,4 +55,4 @@ public class RemoveKeyCommand implements Command { flats.remove(idToDelete); return "Successfully deleted flat!"; } -} \ No newline at end of file +}