Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pattern to handle a commands #144

Open
wants to merge 1 commit into
base: shtramak
Choose a base branch
from

Conversation

Shtramak
Copy link

@Shtramak Shtramak commented Apr 4, 2018

No description provided.

while (true) {
String command = view.read();
handler.handleCommand(command);
if (command.toLowerCase().equals("exit")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем этот if, если есть команда exit?)


@Override
public void execute() {
if (databaseManager.hasConnection()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я поэтому сделал 2 метода с коннектом и без, чтобы не городить if else в каждой команде)

}

public void handleCommand(String strCommand) {
if (strCommand.toLowerCase().equals("help")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потом лучше, конечно, это в команду help вытащить)

}
}

private Command getCommandByName(String commandName) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А я не могу понять как отрабатывает connect, если как enum это одно слово connect, а как команда он 4 слова

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants