Skip to content

Commit 91f8c5d

Browse files
authored
Merge branch 'code-differently:main' into Work07
2 parents 310404d + 89614e9 commit 91f8c5d

File tree

87 files changed

+10181
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+10181
-14
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
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Lesson 10 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_10/libraries/**"
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: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
24+
- name: Build Lesson 10 with Node.js
25+
working-directory: ./lesson_10/libraries
26+
run: |
27+
npm ci
28+
npm run check

.github/workflows/check_push.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,13 @@ jobs:
9393
run: |
9494
npm ci
9595
npm run compile
96+
97+
- name: Build Lesson 09 with Gradle
98+
working-directory: ./lesson_09/types
99+
run: ./gradlew check
100+
101+
- name: Build Lesson 10 with Node.js
102+
working-directory: ./lesson_10/libraries
103+
run: |
104+
npm ci
105+
npm run compile

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+

lesson_09/README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,28 @@ Please review the following resources before lecture:
1010

1111
## Homework
1212

13-
- TODO(anthonydmays): Add homework details
13+
- [ ] Complete [data types exercise](#choosing-the-right-data-types).
14+
15+
### Choosing the Right Data Types
16+
17+
For this exercise, you will use your knowledge of data types to identify the appropriate type to store and process data. You will run a program to generate a unique file with sample data, then write code to provide the correct data type of each column.
18+
19+
1. Execute the app providing a unique provider name.
20+
21+
```bash
22+
cd lesson_09/types
23+
./gradlew bootRun --args="yourprovidername" # Substitute with your own value
24+
```
25+
2. Examine the file that was created for you in the [resources/data][resources-folder] folder. The file will be formatted using the [JSON][json-link] data format.
26+
3. Next, you will create a `DataProvider` implementation that will provide information about the data types for the columns in the file (e.g. `column1`, `column2`, etc.). You can view the example [AnthonyMaysProvider.java][example-file] file.
27+
4. Customize the data types map by choosing the closest appropriate data type of each column. Each data type should only be used **once**.
28+
5. Make sure to apply the formatter and run the tests to confirm that you've implemented everything correctly.
29+
```bash
30+
./gradlew spotlessApply
31+
./gradlew check
32+
```
33+
6. You are to submit a PR with your `DataProvider` implementation and the generated `.json` file that was produced for you. All build checks must pass in order to receive full credit.
34+
35+
[json-link]: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON
36+
[resources-folder]: ./types/types_app/src/main/resources/data/
37+
[example-file]: ./types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/AnthonyMaysProvider.java

lesson_09/types/.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

lesson_09/types/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
Binary file not shown.

0 commit comments

Comments
 (0)