-
Notifications
You must be signed in to change notification settings - Fork 7
1,2 Tasks from PR1 done #7
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?
Conversation
| boolean start = true; | ||
| while (start) { | ||
| System.out.println("Make your choice."); | ||
| Scanner sc = new Scanner(System.in); |
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.
Creating scanner in each iteration is not a good idea.
|
|
||
| private static void exit() { | ||
| System.out.println("Bye-bye"); | ||
| System.exit(0); |
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.
It's a bad practice to use System.exit(). Please get rid of it.
|
|
||
| } | ||
|
|
||
| private static void 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.
What about help message?
| System.out.println("Make your choice."); | ||
| Scanner sc = new Scanner(System.in); | ||
| String choice = sc.nextLine(); | ||
| choice.toLowerCase(); |
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.
It's not working properly because string is immutable. Please read documentation about string methods.
| case "help": | ||
| help(); | ||
| break; | ||
| default: |
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.
I'd prefer print help message by default.
| System.out.println("Enter second number:"); | ||
| b = sc.nextInt(); | ||
| result = a / b; | ||
| System.out.println("Result of " + a + "/" + b + " is " + result); |
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.
Please use String.format
| System.exit(0); | ||
| } | ||
|
|
||
| private static void div() { |
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 are too many duplicated code... Reading two integers for example. Maybe you can get rid of it?
3 task will be done soon