diff options
| author | mokha <mokha@cisco.com> | 2019-05-13 21:43:16 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-13 21:43:16 -0600 |
| commit | 3577d7930d626f55007ee02ca69331699c5bbc8d (patch) | |
| tree | 0e19f5a45e44fce22df6af80125f564fbcbce87a /src | |
| parent | 2b469c027a59b1ba4125e2d7ab6a970e3deaa186 (diff) | |
update program profiles
Diffstat (limited to 'src')
| -rw-r--r-- | src/Q3/README.md | 80 | ||||
| -rw-r--r-- | src/Q4/README.md | 96 | ||||
| -rw-r--r-- | src/Q5/README.md | 92 | ||||
| -rw-r--r-- | src/Q6/README.md | 85 | ||||
| -rw-r--r-- | src/Q7/README.md | 87 | ||||
| -rw-r--r-- | src/Q8/README.md | 87 | ||||
| -rw-r--r-- | src/Q9/README.md | 83 |
7 files changed, 572 insertions, 38 deletions
diff --git a/src/Q3/README.md b/src/Q3/README.md index 8c880cb..3edb62a 100644 --- a/src/Q3/README.md +++ b/src/Q3/README.md @@ -17,15 +17,85 @@ For example, the distance between the points (−2, −3) and (−4, 4) is appro [Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +I took the example described in the problem statement and converted it +to a junit test. Then I implemented the `calculateDistance` interface. + 3. Errors and Warnings: -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 48 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.046 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec + +Results : +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.899 s +[INFO] Finished at: 2019-05-13T21:15:06-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: -[Provide some test cases with sample input and output of your program.] -5. Discussion: +Tests are available in `CartesianCoordinateSystemTest.java`. -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +5. Discussion: diff --git a/src/Q4/README.md b/src/Q4/README.md index f3e1359..80a84eb 100644 --- a/src/Q4/README.md +++ b/src/Q4/README.md @@ -38,15 +38,103 @@ Finally, print the name and number of years participated for each runner if the [Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +I followed the instructions in the assignment and created a class the +inherits from `AddressBook`. The sub class has a single constructor that +chains to the super class constructor. + +I did an override of the `Comparable<AddressBook>` interface to compare +using the runners time instead of the default comparison from the base +class. + +Java's implementation of generics doesn't allow a class to +implement the same generic interface using a different type parameter. +So I had to downcast the `AddressBook` to a `BanffMarathonRunner`. The +`compareTo` implementation in the subclass always assums that it is +being compared to another `BanffMarathonRunner`. + +Sorting arrays becomes very using after implementing the `Comparable<T>` +interface. + 3. Errors and Warnings: -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 46 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.05 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec + +Results : + +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.893 s +[INFO] Finished at: 2019-05-13T21:20:12-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: -[Provide some test cases with sample input and output of your program.] + +Tests are available in `BanffMarathonRunnerTest.java`. 5. Discussion: -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +The implementation of `getAboveAverageRunners` assumes that `better` +is less than or equal to the average time taken by all runners. diff --git a/src/Q5/README.md b/src/Q5/README.md index 444a28f..c46f8da 100644 --- a/src/Q5/README.md +++ b/src/Q5/README.md @@ -21,17 +21,99 @@ Then, display the final account value for each of the 15 runners. 2. Description of the Code: -[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +I created a constructor overload that accepts the `monthlyContribution` +as a parameter. This made it easier to write unit tests rather than +depend on random monthlyContributions. The constructor that accepts a +`firstName` and `lastName` will generate a random `monthlyContribution` +and chain to the overloaded constructor. + +I had no idea what `d1` and `d2` means, so I didn't use those +parameters. + +I designed this class so that you could predict the future value for `n` +months from now. I did assign the `accountValue` to a prediction of 12 +months from now. I would have preferred to implement an interface that +didn't require private instance variables and rather depend on +calculations on the fly but I did my best to bride the requirements with +my own preferences. 3. Errors and Warnings: -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 47 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec + +Results : +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 3.620 s +[INFO] Finished at: 2019-05-13T21:26:40-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: [Provide some test cases with sample input and output of your program.] -5. Discussion: +Tests are available in `EmployeeSavingsTest.java`. -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +5. Discussion: diff --git a/src/Q6/README.md b/src/Q6/README.md index 5c076e9..594f920 100644 --- a/src/Q6/README.md +++ b/src/Q6/README.md @@ -35,17 +35,90 @@ b. a=28, b=45, c=53 2. Description of the Code: -[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +The `Triangle` class accepts the length of size `A`, `B`, and `C` in the +constructor. I used the constant `Triangle.NULL` to represent a null +value, to indicate which side needed to be calculated. -3. Errors and Warnings: +I assumed only side `B` needed to be calculated based on the problem +description but could have also checked side `A` or `C`. -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +3. Errors and Warnings: +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 47 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec + +Results : + +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 3.620 s +[INFO] Finished at: 2019-05-13T21:26:40-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: [Provide some test cases with sample input and output of your program.] -5. Discussion: +Tests are available in `TriangleTest.java`. -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +5. Discussion: diff --git a/src/Q7/README.md b/src/Q7/README.md index 8f79356..df7e40c 100644 --- a/src/Q7/README.md +++ b/src/Q7/README.md @@ -45,20 +45,91 @@ although it goes by many other names as well. Write a program that reads in a number from the user and then displays the Hailstone sequence for that number, followed by a line showing the number of steps taken to reach 1. - 2. Description of the Code: -[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +My first implementation of this algorithm used an iterative approach. I +later changed it to use a recursive approach because I felt the code was +a little bit easier to read and blowing the stack or performance wasn't +a big concern for this exercise. -3. Errors and Warnings: +The base case for the recursion is `n == 1`. -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +3. Errors and Warnings: +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 48 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.05 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec + +Results : + +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.912 s +[INFO] Finished at: 2019-05-13T21:33:23-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: -[Provide some test cases with sample input and output of your program.] -5. Discussion: +Tests can be found in `HailstoneSequenceTest.java`. -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +5. Discussion: diff --git a/src/Q8/README.md b/src/Q8/README.md index 41d24cd..706d676 100644 --- a/src/Q8/README.md +++ b/src/Q8/README.md @@ -30,17 +30,92 @@ Write a program that will help Google to programmatically determine eligibility 2. Description of the Code: -[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +I created two classes to solve this problem. The first class is the +`Candidate` class and the second is the `Communication` class. I used +the `Communication` class to control sort order and precedence of one +communication level with another using the `Comparable<T>` interface. + +In the `Candidate` class I created a method called `isEligible` that +calculates if the candidate is eligible for a position at the company. 3. Errors and Warnings: -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 47 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.057 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec + +Results : + +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.907 s +[INFO] Finished at: 2019-05-13T21:37:20-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: -[Provide some test cases with sample input and output of your program.] -5. Discussion: +Tests are available in `CandidateTest.java` and `CommunicationTest.java`. -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] + +5. Discussion: diff --git a/src/Q9/README.md b/src/Q9/README.md index c835bc9..550cfb7 100644 --- a/src/Q9/README.md +++ b/src/Q9/README.md @@ -16,17 +16,92 @@ If the number is prime, print “prime”. 2. Description of the Code: -[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] +Most of the methods implemented required some for of modulus division. I +was able to extract a method called `isDivisibleBy` that I was able to +reuse quite a bit. 3. Errors and Warnings: -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 48 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec + +Results : + +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.844 s +[INFO] Finished at: 2019-05-13T21:40:21-06:00 +[INFO] ------------------------------------------------------------------------ +``` 4. Sample Input and Output: [Provide some test cases with sample input and output of your program.] +Tests are available in `NumberTest.java`. + 5. Discussion: -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +The implementation of the `isPrime` method is very naive and will work +for small values of `n`. It uses a brute force approach without any form +of memoization. |
