Conversation
| * @return The number of milliseconds equivalent to the given number of minutes. | ||
| */ | ||
| Integer MILLISECONDS_PER_MINUTE = null; // Make this value a constant | ||
| Integer MILLISECONDS_PER_MINUTE = 60000; // Make this value a constant |
Check warning
Code scanning / PMD
Field declaration for 'MILLISECONDS_PER_MINUTE' should be before method declarations in its class Warning
| * @return The number of milliseconds equivalent to the given number of minutes. | ||
| */ | ||
| Integer MILLISECONDS_PER_MINUTE = null; // Make this value a constant | ||
| Integer MILLISECONDS_PER_MINUTE = 60000; // Make this value a constant |
Check warning
Code scanning / PMD
The instance field name 'MILLISECONDS_PER_MINUTE' doesn't match '[a-z][a-zA-Z0-9]*' Warning
| public static Double convertFahrenheitToCelsius(Double fahrenheit) { | ||
| final Double SUBTRACT_FACTOR = 32.0; | ||
| final Double MULTIPLY_FACTOR = 5.0; | ||
| final Double MULTIPLY_FACTOR = 5.0; |
Check warning
Code scanning / PMD
The final local variable name 'MULTIPLY_FACTOR' doesn't match '[a-z][a-zA-Z0-9]*' Warning
walters954
left a comment
There was a problem hiding this comment.
Review Summary for Nedrick
Hey Nedrick! Thanks for submitting your work on Module 1. I can see you've put in real effort here, and you're clearly starting to grasp the fundamentals of Apex programming. Let me share some feedback to help you level up!
What You Did Well
- Order of Operations: Your solutions for
adjustOrderOfOperations1,adjustOrderOfOperations2, andcomplexOrderOfOperationsshow a solid understanding of PEMDAS and how parentheses affect calculation order. Great work! - Boolean Logic: The
isEvenandisPositivemethods are implemented correctly - you used the parameters directly and wrote clean, concise code. - Date Comparisons: Your
isDateInPastandisDateTodayOrFuturemethods correctly useDate.today()and proper comparison operators. - Formula Implementation: You correctly implemented the temperature conversion, paycheck calculations, and tax formulas.
Key Area to Improve
There's one important concept that needs adjustment throughout your code: using method parameters.
When a method is defined with parameters like public static Integer addition(Integer a, Integer b), the values a and b are provided by whoever calls your method. You should use these values directly, not replace them with hardcoded values.
Example of the issue:
public static Integer addition(Integer a, Integer b) {
Integer a = 4; // This creates a NEW variable that hides the parameter
Integer b = 16; // This creates a NEW variable that hides the parameter
return a + b; // Always returns 20, ignoring what was passed in
}The fix:
public static Integer addition(Integer a, Integer b) {
return a + b; // Uses the actual values passed to the method
}This pattern affects most of your methods. Once you remove those hardcoded variable declarations, your code should work correctly with the unit tests!
Next Steps
- Go through each method and remove the lines where you re-declare the parameter variables with hardcoded values
- Make sure you're using the original parameter names to perform your calculations
- Run the unit tests again to verify everything works
You're on the right track - this is a common learning moment when first working with methods and parameters. Keep up the great work, and feel free to reach out if you have questions!
Reviewer: Cloud Code Academy
| return null; // Replace null with the variable you used to store the result | ||
| Integer a = 4; | ||
| Integer b = 16; | ||
| Integer sum = a + b; |
There was a problem hiding this comment.
Great job starting to work through these exercises! I can see you understand the core concepts of arithmetic operations and variable declarations.
However, there's one critical pattern I notice throughout your code that we need to address. When a method has parameters (like Integer a, Integer b here), those values are passed IN when someone calls your method. You should use those parameter values directly rather than declaring new variables with the same names and hardcoded values.
What's happening now:
public static Integer addition(Integer a, Integer b) {
Integer a = 4; // This shadows the parameter 'a' with a new variable
Integer b = 16; // This shadows the parameter 'b' with a new variable
Integer sum = a + b;
return sum; // Always returns 20, regardless of what's passed in
}What it should be:
public static Integer addition(Integer a, Integer b) {
// Use the parameters directly - they already contain the values!
Integer sum = a + b;
return sum;
}This way, when someone calls addition(5, 10), your method will correctly return 15 instead of always returning 20.
This same pattern applies to most of the other methods in this file. Once you fix this, your code should pass the unit tests!
| */ | ||
| public static Boolean isEven(Integer num) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| return Math.mod(num, 2) == 0; // Replace null with the variable you used to store the result |
There was a problem hiding this comment.
Excellent work on these two methods! You nailed it here by using the parameters directly instead of re-declaring them with hardcoded values.
isEven correctly uses Math.mod(num, 2) == 0 - this is exactly how you check if a number is even in Apex.
isPositive correctly uses num > 0 - simple and elegant!
This is the pattern you should apply to the other methods as well. Great job on these!
| public static Boolean isDateInPast(Date dt) { | ||
| return null; // Replace null with the variable you used to store the result | ||
| Date today = Date.today(); | ||
| Boolean isInPast = dt < today; |
There was a problem hiding this comment.
Nice work on the date comparison logic! You correctly used Date.today() to get the current date and compared it properly.
Just remember to remove the hardcoded variable re-declarations in similar methods and use the dt parameter that's passed in - which you're already doing here correctly!
| * @return The number of milliseconds equivalent to the given number of minutes. | ||
| */ | ||
| Integer MILLISECONDS_PER_MINUTE = null; // Make this value a constant | ||
| Integer MILLISECONDS_PER_MINUTE = 60000; // Make this value a constant |
There was a problem hiding this comment.
Good job defining the constant value! One small improvement: to make this a true constant in Apex, you should add the static final keywords:
static final Integer MILLISECONDS_PER_MINUTE = 60000;The final keyword means the value cannot be changed after it's set, and static means it belongs to the class rather than an instance. This is a best practice for constants in Apex.
| // 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; |
There was a problem hiding this comment.
Great job on this one! You correctly added parentheses to change the order of operations from 48 - 15 + 5 * 2 = 43 to 48 - (15 + 5) * 2 = 8.
This shows a solid understanding of how parentheses affect the order of operations (PEMDAS). Well done!
👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to the default branch since the assignment started. Your teacher can see this too.
Notes for teachers
Use this PR to leave feedback. Here are some tips:
For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @Nedrick-Rondre