-
Notifications
You must be signed in to change notification settings - Fork 0
Feedback #1
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: feedback
Are you sure you want to change the base?
Feedback #1
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 |
|---|---|---|
|
|
@@ -32,7 +32,12 @@ | |
| * @return The sum of the two numbers, or null if either number is null. | ||
| */ | ||
| public static Integer addition(Integer a, Integer b) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| if(a == null || b == null){ | ||
| return null; | ||
| } | ||
|
|
||
| Integer sum = a + b; | ||
| return sum; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -44,7 +49,8 @@ | |
| * @return The difference between the two numbers. | ||
| */ | ||
| public static Integer subtraction(Integer a, Integer b) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Integer difference = a -b; | ||
|
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. Nice work with the null check here! 👍 For consistency, you might also want to add similar null checking to other methods that take Integer parameters, like |
||
| return difference; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -56,7 +62,8 @@ | |
| * @return The product of the two numbers. | ||
| */ | ||
| public static Integer multiplication(Integer a, Integer b) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Integer product = a * b; | ||
| return product; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -69,7 +76,12 @@ | |
| * @return The quotient of the division, or 0 if the denominator is zero. | ||
| */ | ||
| public static Double division(Double a, Double b) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| if(b == 0){ | ||
| return 0; | ||
| } | ||
|
|
||
| Double quotient = a / b; | ||
| return quotient; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -83,7 +95,8 @@ | |
| * @return True if the number is even, False otherwise. | ||
| */ | ||
| public static Boolean isEven(Integer num) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Boolean isEven = Math.mod(num, 2) == 0; | ||
| return isEven; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -94,7 +107,8 @@ | |
| * @return true if the number is positive, false otherwise. | ||
| */ | ||
| public static Boolean isPositive(Integer num) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Boolean isPositive = num > 0; | ||
| return isPositive; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -106,7 +120,8 @@ | |
| * @return The concatenated string. | ||
| */ | ||
| public static String concatenateStrings(String str1, String str2) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| String jointString = str1 + str2; | ||
| return jointString; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -121,7 +136,8 @@ | |
| * @return The complete sentence as a single String. | ||
| */ | ||
| public static String createSentence(String noun, String verb, String endingPunctuation) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| String completeSentence = 'The ' + noun + ' is ' + verb + endingPunctuation; | ||
| return completeSentence; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -134,7 +150,8 @@ | |
| * @return True if the date is in the past, False otherwise. | ||
| */ | ||
| public static Boolean isDateInPast(Date dt) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Boolean dateInThePast = dt < System.Today(); | ||
| return dateInThePast; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -147,7 +164,8 @@ | |
| * @return True if the date is today or in the future, False otherwise. | ||
| */ | ||
| public static Boolean isDateTodayOrFuture(Date dt) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Boolean dateIsTodayOrLater = dt >= System.Today(); | ||
| return dateIsTodayOrLater; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -159,10 +177,11 @@ | |
| * @param minutes The number of minutes. | ||
| * @return The number of milliseconds equivalent to the given number of minutes. | ||
| */ | ||
| Integer MILLISECONDS_PER_MINUTE = null; // Make this value a constant | ||
| Static Integer MILLISECONDS_PER_MINUTE = 60000; // Make this value a constant | ||
Check warningCode scanning / PMD Field declaration for 'MILLISECONDS_PER_MINUTE' should be before method declarations in its class Warning
Field declaration for 'MILLISECONDS_PER_MINUTE' should be before method declarations in its class
Check warningCode scanning / PMD The static field name 'MILLISECONDS_PER_MINUTE' doesn't match '[a-z][a-zA-Z0-9]*' Warning
The static field name 'MILLISECONDS_PER_MINUTE' doesn't match '[a-z][a-zA-Z0-9]*'
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. Small typo here: Java/Apex keywords are case-sensitive, so this should be lowercase static final Integer MILLISECONDS_PER_MINUTE = 60000;The code still works because Apex is somewhat forgiving, but following proper casing conventions is important for maintainability! |
||
|
|
||
Check warningCode scanning / regex Found trailing whitespace at the end of a line of code. Warning
Found trailing whitespace at the end of a line of code.
|
||
| public static Integer convertMinutesToMilliseconds(Integer minutes) { | ||
| Integer milliseconds; | ||
| return null; // Replace null with the variable you used to store the result | ||
| Integer millisecond = minutes * MILLISECONDS_PER_MINUTE; | ||
| return millisecond; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -176,7 +195,8 @@ | |
| * @return The average of the three numbers. | ||
| */ | ||
| public static Double averageOfThreeNumbers(Integer a, Integer b, Integer c) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Double mean = (a + b + c) / 3; | ||
|
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. Great job on this method! One thing to watch out for: when you divide integers, the result is truncated (rounded down) before being converted to a Double. For a more accurate average, you could use: Double mean = (a + b + c) / 3.0;By using
It's a subtle but important distinction when working with averages! |
||
| return mean; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -191,10 +211,10 @@ | |
| */ | ||
| public static Integer adjustOrderOfOperations1(Integer a, Integer b, Integer c) { | ||
| // Add parentheses around the addition operation so that it is performed before multiplication | ||
| Integer result = a + b * c; | ||
| Integer result = (a + b) * c; | ||
|
|
||
| // Return the result | ||
| return null; // Replace null with the variable you used to store the result | ||
| return result; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -206,8 +226,8 @@ | |
| // Add parentheses in the below expression to change the result. | ||
| // The result of the expression as it is right now is 43. | ||
| // You should add parentheses so that the result of the expression becomes 8. | ||
| Integer answer = 48 - 15 + 5 * 2; | ||
| return null; // Replace null with the variable you used to store the result | ||
| Integer answer = 48 - (15 + 5) * 2; | ||
| return answer; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -226,9 +246,9 @@ | |
| */ | ||
| public static Double complexOrderOfOperations(Integer a, Integer b, Integer c, Integer d, Integer e) { | ||
| // Add parentheses around the multiplication and subtraction operations so that they are performed before division and addition | ||
| Double result = a * b - c / (Double) d + e; | ||
| Double result = (a * b - c) / (Double) d + e; | ||
|
|
||
| return null; // Replace null with the variable you used to store the result | ||
| return result; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -242,8 +262,10 @@ | |
| final Double SUBTRACT_FACTOR = 32.0; | ||
| final Double MULTIPLY_FACTOR = 5.0; | ||
| final Double DIVIDE_FACTOR = 9.0; | ||
|
|
||
| Double celciusTemp = (fahrenheit - SUBTRACT_FACTOR) * (MULTIPLY_FACTOR / DIVIDE_FACTOR); | ||
|
|
||
| return null; // Replace null with the variable you used to store the result | ||
| return celciusTemp; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -259,11 +281,11 @@ | |
| */ | ||
| public static Integer performDivisionAndCast(Double a, Double b) { | ||
| // Perform the division and cast (round down) off the result. | ||
| Double divisionResult = null; | ||
| Double divisionResult = a / b; | ||
|
|
||
| // Write the code for type casting the divisionResult to an Integer | ||
| Integer roundedResult = null; | ||
| return null; // Replace null with the variable you used to store the result | ||
| Integer roundedResult = (Integer) divisionResult; | ||
| return roundedResult; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -277,7 +299,8 @@ | |
| */ | ||
| public static Decimal calculateWeeklyPaycheck(Decimal hourlyRate, Double numberOfHours) { | ||
| // Calculate the weekly paycheck using the formula: rate multiplied by hours | ||
| return null; // Replace null with the variable you used to store the result | ||
| Decimal weeklyPaycheck = hourlyRate * numberOfHours; | ||
| return weeklyPaycheck; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -291,7 +314,8 @@ | |
| * @return A Decimal representing the monthly paycheck. | ||
| */ | ||
| public static Decimal calculateMonthlyPaycheck(Decimal hourlyRate, Double numberOfHours) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Decimal monthlyPaycheck = hourlyRate * numberOfHours * 4; | ||
| return monthlyPaycheck; // Replace null with the variable you used to store the result | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -305,6 +329,7 @@ | |
| * @return The total cost after applying the sales tax. | ||
| */ | ||
| public static Decimal calculateTotalCost(Decimal pricePerUnit, Integer numberOfUnits, Decimal salesTaxRate) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Decimal totalCostWithTax = (pricePerUnit * numberOfUnits) * (1 + salesTaxRate); | ||
| return totalCostWithTax; // Replace null with the variable you used to store the result | ||
| } | ||
| } | ||
Check warning
Code scanning / regex
Found trailing whitespace at the end of a line of code. Warning