Skip to content

Commit 74c58ee

Browse files
authored
Merge branch 'code-differently:main' into release/David.A-lesson7hw
2 parents e0406f2 + 1ceb863 commit 74c58ee

File tree

14 files changed

+722
-13
lines changed

14 files changed

+722
-13
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check Lesson 09 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_09/types/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
25+
- name: Build Lesson 09 with Gradle
26+
working-directory: ./lesson_09/types
27+
run: ./gradlew check

lesson_04/dylanlafferty/ReadME.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## Java Implementation
2+
3+
```class PrimeChecker {
4+
public static boolean isPrime(int number) {
5+
if (number <= 1) {
6+
return false;
7+
}
8+
9+
// Check if number is divisible by any number from 2 to sqrt(number)
10+
for (int i = 2; i <= Math.sqrt(number); i++) {
11+
if (number % i == 0) {
12+
return false;
13+
}
14+
}
15+
return true;
16+
}
17+
18+
public static void main(String[] args) {
19+
int num1 = 11; //This number may be changed to change the input
20+
int num2 = 15; //This one too
21+
System.out.println(num1 + " is prime: " + isPrime(num1));
22+
System.out.println(num2 + " is prime: " + isPrime(num2));
23+
}
24+
}
25+
```
26+
27+
## JavaScript implementation
28+
29+
```
30+
// let number = prompt("Enter a number to check if it is a Prime number");
31+
32+
function checkPrime(number) {
33+
if (number === null || number === undefined) {
34+
console.log("You have not entered a number");
35+
return;
36+
}
37+
38+
if (number <= 1) {
39+
console.log("This is not a prime number");
40+
return false; // Numbers less than or equal to 1 are not prime
41+
}
42+
43+
for (let i = 2; i < Math.sqrt(number); i++) {
44+
if (number % i === 0) {
45+
console.log("This is not a prime number");
46+
return false; // If divisible by any number other than 1 and itself
47+
}
48+
}
49+
50+
console.log("This is a prime number");
51+
return true; // If no divisors were found, the number is prime
52+
}
53+
54+
console.log(checkPrime(45)); //
55+
console.log(checkPrime(23)); //
56+
console.log(checkPrime(13)); //
57+
```
58+
59+
## Explaination
60+
61+
The Java
62+
The Java implementation uses a class named `PrimeChecker`. `PrimeChecker` will get an integer named `number` and run it through 2 tests. The first test will be to see if `number` is less than or greater than 1 which then will return `false`. It will then see if the number is able to be divided by anything other than itself and if not then it will return `True`.
63+
64+
The JavaScript implementation uses a function named `checkPrime`. `CheckPrime` first checks if a `number` has been entered. If a `number` has been entered and if it is less than or equal to 1 it will return `True`. If this passes the for loop will run and see if that `number` can be divided into itself and if it can then return `False`.
65+
66+
## Similarites
67+
1. **Syntax**
68+
- Both languages write If statements in the same way using `if(instance) { code } `.
69+
- The For Loop are both written using `for` and adding the statements inside of `(statement1)`.
70+
- Math works the same in both languages using the `%` for division.
71+
2. **Input Fields**
72+
- Both Languages can have a predefined input inside of the code.
73+
- Both Languages can return either `true` or `false` to the console.
74+
75+
## Differences
76+
1. **Syntax**
77+
- In `Java` there are two Static functions but one it required to be defined as main. However in `JavaScript` you do not need to define a main function.
78+
- In `Java` in order to print something you have to write a `system.out.print` compared to `JavaScript` It uses the `console.log`.
79+
2. ## Declarations
80+
- With `Java` You have to let the computer know what type of input you are giving it. So if you would want to give a variable a number you need to declare that as an integer or `int`. While you can just write a number out in `javaScript`.
81+

lesson_04/ezra4/README.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,47 @@
11
## Python Implementation
22

33
```python
4-
def prime_num(num):
4+
def is_prime(num):
55
if num <= 1:
66
return False
7-
for i in range(2, num):
7+
for i in range(2, num):
88
if num % i == 0:
99
return False
1010
return True
11+
12+
def main():
13+
num = int(input("Enter a number: "))
14+
print(f"{num} is prime." if is_prime(num) else f"{num} is not prime.")
15+
16+
if __name__ == "__main__":
17+
main()
1118
```
1219

1320
## Java Implementation
1421

1522

1623
```java
17-
public static void main(String[] args) {
18-
Scanner scanner = new Scanner(System.in);
19-
System.out.print("Enter a number:");
20-
int num = scanner.nextInt();
21-
22-
if (isPrime(num)) {
23-
System.out.println(num + " is prime.");
24+
import java.util.Scanner;
25+
26+
public class PrimeChecker {
27+
public static void main(String[] args) {
28+
Scanner scanner = new Scanner(System.in);
29+
System.out.print("Enter a number: ");
30+
int num = scanner.nextInt();
31+
System.out.println(num + (isPrime(num) ? " is prime." : " is not prime."));
32+
scanner.close();
2433
}
25-
else {
26-
System.out.println(num + " is not prime.");
34+
35+
public static boolean isPrime(int num) {
36+
if (num <= 1) {
37+
return false;
38+
}
39+
for (int i = 2; i < num; i++) {
40+
if (num % i == 0) {
41+
return false;
42+
}
43+
}
44+
return true;
2745
}
2846
}
2947
```
@@ -46,5 +64,6 @@ In java we have a different approach. Unlike python we define our class using `(
4664

4765
2. Java uses `System.out.print()` to print out the statement and python uses `print()` to print statement.
4866

49-
50-
3. I notice i have to import `java.util.Scanner` to prompt user to input a number while python you only need to use, `input()`
67+
3. I notice i have to import `java.util.Scanner` to prompt user to input a number while python you only need to use, `input()`
68+
4. Java uses `{}` for blocks and `;` to end statement while python doesn't need semicolons.
69+

lesson_05/dylanlafferty/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
## Three user Stories
4+
```
5+
1. As a `Line Cook`, `I want ` an application that allows me to see an easy-to-read ticket that only displays items that belong to my station on that ticket. `So that` I can quickly make entrees faster and be able to focus on what is on my stations end other than the other stations.
6+
7+
2. As a `Software engineer`, `I want` a program that will allow me to drag and drop different css elements, `So that` I can efficently create a custom webpage without having to spend hours making the perfect CSS.
8+
9+
3. As a `Inventory Stock`, `I want` a program that will keep track of items in my storage and when that item hits a certain number it will automatically send order. `So that` I can automate my storage process and spend time reordering on other tasks in the store.
10+
```
11+
12+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson9.dataprovider;
2+
3+
import java.util.Map;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class DavisDProvider extends DataProvider {
8+
public String getProviderName() {
9+
return "davis.d";
10+
}
11+
12+
public Map<String, Class> getColumnTypeByName() {
13+
return Map.of(
14+
"column1", Float.class,
15+
"column2", String.class,
16+
"column3", Integer.class,
17+
"column4", Boolean.class,
18+
"column5", Double.class,
19+
"column6", Short.class,
20+
"column7", Long.class);
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson9.dataprovider;
2+
3+
import java.util.Map;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class DylanLafferty extends DataProvider {
8+
public String getProviderName() {
9+
return "dylanlafferty";
10+
}
11+
12+
public Map<String, Class> getColumnTypeByName() {
13+
return Map.of(
14+
"column1", Integer.class,
15+
"column2", Boolean.class,
16+
"column3", Double.class,
17+
"column4", Float.class,
18+
"column5", Long.class,
19+
"column6", String.class,
20+
"column7", Short.class);
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson9.dataprovider;
2+
3+
import java.util.Map;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class EvanPhilakhongProvider extends DataProvider {
8+
public String getProviderName() {
9+
return "evanphilakhong";
10+
}
11+
12+
public Map<String, Class> getColumnTypeByName() {
13+
return Map.of(
14+
"column1", Float.class,
15+
"column2", String.class,
16+
"column3", Long.class,
17+
"column4", Double.class,
18+
"column5", Integer.class,
19+
"column6", Boolean.class,
20+
"column7", Short.class);
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson9.dataprovider;
2+
3+
import java.util.Map;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class MeikoStephensProvider extends DataProvider {
8+
public String getProviderName() {
9+
return "meikostephens";
10+
}
11+
12+
public Map<String, Class> getColumnTypeByName() {
13+
return Map.of(
14+
"column1", Long.class,
15+
"column2", Float.class,
16+
"column3", Double.class,
17+
"column4", Short.class,
18+
"column5", String.class,
19+
"column6", Boolean.class,
20+
"column7", Integer.class);
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codedifferently.lesson9.dataprovider;
2+
3+
import java.util.Map;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class MercedesMathewsProvider extends DataProvider {
8+
public String getProviderName() {
9+
return "mercedesmathews";
10+
}
11+
12+
public Map<String, Class> getColumnTypeByName() {
13+
return Map.of(
14+
"column1", String.class,
15+
"column2", Long.class,
16+
"column3", Integer.class,
17+
"column4", Float.class,
18+
"column5", Boolean.class,
19+
"column6", Double.class,
20+
"column7", Short.class);
21+
}
22+
}

0 commit comments

Comments
 (0)