-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: shtramak
Are you sure you want to change the base?
Conversation
while (true) { | ||
String command = view.read(); | ||
handler.handleCommand(command); | ||
if (command.toLowerCase().equals("exit")) { |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А я не могу понять как отрабатывает connect, если как enum это одно слово connect, а как команда он 4 слова
No description provided.