This project is designed for Mr. Hare's APCS-A, focusing on Unit 3 concepts such as conditional statements, Boolean expressions, and logical operators. The project includes a set of methods that students need to implement, along with unit tests to verify their functionality.
Unit3.java: Contains method headers and task descriptions. Students are required to implement the method bodies.Unit3Test.java: JUnit test cases for each method inUnit3.java. These tests validate the correctness of the implemented methods.pom.xml: Maven configuration file that manages dependencies and plugins required to build and run the project.
- Java 17 (or compatible version)
- Maven 3.x
Use link found in Google Classroom to accept in GitHub Classroom
Clone this repository to your local machine using GitHub Desktop.
Run the JUnit tests to verify your implementations
Students need to implement the following methods in Unit3.java:
isPositive(int number): Returnstrueif the number is positive, otherwisefalse.isWithinRange(int number, int lower, int upper): Returnstrueif the number is within the specified range (inclusive).isLeapYear(int year): Determines if a year is a leap year based on given rules.areBothSameSign(int number1, int number2): Checks if both numbers have the same sign (either positive or negative).containsSubstring(String main, String sub): Returnstrueif the main string contains the substring and both are not empty.reversePhoneNumber(int phoneNumber): Reverses the given phone number using modulo operations.
- Using
=instead of==in conditionals. - Ending
ifstatements with a semicolon (;). - Using multiple
ifstatements whenif-elsewould be more appropriate. - Misunderstanding the use of logical operators (
&&,||). - Failing to apply short-circuit evaluation correctly.
Feel free to submit issues or pull requests if you find bugs or have suggestions for improvement.
For any questions, please contact Mr. Hare.