-
Notifications
You must be signed in to change notification settings - Fork 7
not all #9
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?
not all #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,26 @@ | ||
| package school.lemon.changerequest.java.introduction.pr1; | ||
|
|
||
|
|
||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| public class Bob { | ||
|
|
||
| public static String hey(String phrase) { | ||
| return ""; | ||
|
|
||
|
|
||
| if (phrase.equals(phrase.toUpperCase()) ) { | ||
| return "Chill out!"; | ||
| } | ||
| else if (phrase.endsWith("?")) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please format your code. |
||
| return "Yeap."; | ||
| } | ||
| String trimmed = phrase.trim(); | ||
| if (trimmed.isEmpty()) { | ||
| return "Fine."; | ||
| } | ||
|
|
||
| return "Whatever."; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,62 @@ | ||
| package school.lemon.changerequest.java.introduction.pr1; | ||
|
|
||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| public class ConsoleCalculator { | ||
| public int Add(int scannetFirstNumInt, int scannetSecondNumInt, String scannerOperations) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use lowerCamelCase for method names https://ru.wikipedia.org/wiki/CamelCase |
||
| if (scannerOperations.equals("add")) | ||
| { | ||
| return scannetFirstNumInt + scannetSecondNumInt;} | ||
| return 0; | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| public int Sub(int scannerFirstNum, int scannerSecondNum) { | ||
| return scannerFirstNum - scannerSecondNum; | ||
| } | ||
|
|
||
| public int Mul(int scannerFirstNum, int scannerSecondNum) { | ||
| return scannerFirstNum * scannerSecondNum; | ||
| } | ||
|
|
||
| public int Div(int scannerFirstNum, int scannerSecondNum) { | ||
| return scannerFirstNum / scannerSecondNum; | ||
| } | ||
|
|
||
|
|
||
| public static void main(String[] args) { | ||
| System.out.println("Console calculator:"); | ||
| System.out.println("Enter 'add' to perform addition."); | ||
| System.out.println("Enter 'sub' to perform subtraction."); | ||
| System.out.println("Enter 'mul' to perform multiplication."); | ||
| System.out.println("Enter 'div' to perform division."); | ||
| System.out.println("Enter 'exit' to exit."); | ||
| System.out.println("Enter 'help' to see help message."); | ||
| System.out.println("Make your choice."); | ||
| Scanner scannerOperations = new Scanner(System.in); | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User should have possibility to do more than one operations, so there should be a loop, until user enter |
||
| System.out.println("Enter first number:"); | ||
| Scanner scannerFirstNum = new Scanner(System.in); | ||
| int scannetFirstNumInt; | ||
| if (scannerFirstNum.hasNextInt()) { | ||
| scannetFirstNumInt = scannerFirstNum.nextInt();} | ||
|
|
||
| System.out.println("Enter second number:"); | ||
| Scanner scannerSecondNum = new Scanner(System.in); | ||
| int scannetSecondNumInt; | ||
| if (scannerSecondNum.hasNextInt()) { | ||
| scannetSecondNumInt = scannerSecondNum.nextInt();} | ||
|
|
||
|
|
||
| ConsoleCalculator resultat = new ConsoleCalculator(); | ||
|
|
||
| System.out.println("Result of" + resultat); | ||
| System.out.println("Make your choice."); | ||
| Scanner scannerOperationsSecond = new Scanner(System.in); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One scanner will be enough for reading all numbers and operations, so no reason to create another one. |
||
| System.out.println("Make your choice."); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
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.
The thing is, that
"1 2 3".toUpperCase()is the same as1 2 3.There are two ways, first one - use regexp figure out whether string contains upper case letters. Second one - additionally use
toLowerCase().