-
Notifications
You must be signed in to change notification settings - Fork 7
Pr1-all #8
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
base: master
Are you sure you want to change the base?
Pr1-all #8
Conversation
| "I HATE YOU" || "Chill out!" | ||
| "Wait! Hang on. Are you going to be OK?" || "Yeap." | ||
| " " || "Fine." | ||
| " " || "Fine." |
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.
you shouldn't modify tests.
| } | ||
| } | ||
| char[] aA = a.toCharArray(); | ||
| char[] a1A1 = a1.toCharArray(); |
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.
There is no need for this 2 additional variables.
String has method chatAt that will given you character at some position.
| "Enter 'div' to perform division.\n " + | ||
| "Enter 'exit' to exit.\n " + | ||
| "Enter 'help' to see help message.\n "); | ||
| int exit=1; |
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.
For such purposes it's better to use boolean variables.
| default: System.out.println("WRONG!"); | ||
| break; | ||
|
|
||
| }} |
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.
And what about help command ? I don't see any handler for help.
| System.out.print("Make your choice.\n"); | ||
| Scanner sc = new Scanner(System.in); | ||
| String s1 = sc.nextLine(); | ||
| if (s1.equals("exit")) {System.out.println("Bye-bye."); |
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.
There is actually no need for this check. It'll be better if you could move all possible commands cases into switch statement. And also do not forget about code duplication - create additional functions if they'll help you.
|
|
||
| if (anger==phrase&&anger!=notAnger){return "Chill out!";} | ||
|
|
||
| return "Whatever."; |
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.
You've done lots of operations that could be avoided.
Try to solve task step-by-step, so that if you already know that it's question - don't do anything related to yelling.
Also, there is easier way to check if it's question or not - just use endWith String method.
No description provided.