This repository was archived by the owner on Sep 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Денисова Элина 396 JUnit #559
Open
ElinRin
wants to merge
13
commits into
dkomanov:master
Choose a base branch
from
ElinRin:tsk4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fbf07a4
Денисова Элина 396 JUnit
a584f4f
'
471f62f
''
b48ea02
fixed
801adb0
'
78fd594
size
2d493bf
fixed
9471690
Revert "fixed"
74a7127
fixed
6b0b99f
'
411483b
commands
d0fbf4c
'
aa2e162
2
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/ru/fizteh/fivt/students/elina_denisova/j_unit/Commands.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package ru.fizteh.fivt.students.elina_denisova.j_unit; | ||
|
|
||
| public enum Commands { | ||
|
|
||
| CREATECOMMAND("create"), | ||
| SIZECOMMAND("size"), | ||
| COMMITCOMMAND("commit"), | ||
| ROLLBACKCOMMAND("rollback"), | ||
| DROPCOMMAND("drop"), | ||
| USECOMMAND("use"), | ||
| SHOWCOMMAND("show"), | ||
| PUTCOMMAND("put"), | ||
| GETCOMMAND("get"), | ||
| REMOVECOMMAND("remove"), | ||
| LISTCOMMAND("list"), | ||
| EXITCOMMAND("exit"); | ||
|
|
||
|
|
||
| private String value; | ||
| private Commands(String word) { | ||
| value = word; | ||
| } | ||
|
|
||
| public static Commands getCommand(String word) throws IllegalArgumentException { | ||
| for (Commands command : Commands.values()) { | ||
| if (command.getValue().equals(word)) { | ||
| return command; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException(word + " - unknown command"); | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
src/ru/fizteh/fivt/students/elina_denisova/j_unit/HandlerException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package ru.fizteh.fivt.students.elina_denisova.j_unit; | ||
|
|
||
| public class HandlerException { | ||
| public static void handler(String message, Throwable cause) { | ||
| System.err.println(message + ". " + cause.getMessage()); | ||
| System.exit(1); | ||
| } | ||
| public static void handler(Throwable cause) { | ||
| System.err.println(cause.getMessage()); | ||
| System.exit(1); | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
40 changes: 40 additions & 0 deletions
40
src/ru/fizteh/fivt/students/elina_denisova/j_unit/InteractiveParse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package ru.fizteh.fivt.students.elina_denisova.j_unit; | ||
|
|
||
| import ru.fizteh.fivt.students.elina_denisova.j_unit.commands.Commands; | ||
|
|
||
| import java.util.NoSuchElementException; | ||
| import java.util.Scanner; | ||
|
|
||
| public class InteractiveParse { | ||
| public static void parse(MyTableProvider directory) { | ||
| Scanner in = new Scanner(System.in); | ||
| try { | ||
| while (true) { | ||
| System.out.print("$ "); | ||
| String s; | ||
| s = in.nextLine(); | ||
| s = s.trim(); | ||
| String[] current = s.split("\\s+"); | ||
| for (int i = 0; i < current.length; ++i) { | ||
| current[i].trim(); | ||
| } | ||
| try { | ||
| Commands command = Commands.fromString(current); | ||
| command.execute(directory); | ||
| } catch (NoSuchElementException e) { | ||
| System.err.println(e.getMessage()); | ||
| } | ||
| } | ||
| } catch (IllegalMonitorStateException e) { | ||
| in.close(); | ||
| System.out.println("Goodbye"); | ||
| System.exit(0); | ||
| } catch (NoSuchElementException e) { | ||
| System.err.println(e.getMessage()); | ||
| } catch (Exception e) { | ||
| in.close(); | ||
| HandlerException.handler(e); | ||
| } | ||
| in.close(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Положите все команды в Map и доставайте команды из него, а не так
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.
Кажется, я залила старый вариант -_-