Skip to content

feat: added JSON file and DataProvider file for Chelsea #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c57bb27
Update lesson_05
Cogbonnia Oct 5, 2024
2764b6a
Merge branch 'code-differently:main' into lesson_05
Cogbonnia Oct 7, 2024
ef87526
Merge branch 'code-differently:main' into lesson_05
Cogbonnia Oct 8, 2024
3cc9f6c
Merge branch 'code-differently:main' into lesson_05
Cogbonnia Oct 9, 2024
5cc0b85
Lesson 06: Completed
Cogbonnia Oct 9, 2024
031bdd5
Merge branch 'code-differently:main' into lesson_05
Cogbonnia Oct 9, 2024
f0cc032
Merge branch 'code-differently:main' into lesson_06
Cogbonnia Oct 9, 2024
1812937
Merge branch 'code-differently:main' into lesson_06
Cogbonnia Oct 11, 2024
5c7ac48
Merge branch 'code-differently:main' into lesson_05
Cogbonnia Oct 11, 2024
72adf41
fix: completed the functions
Cogbonnia Oct 11, 2024
72b623b
Merge branch 'code-differently:main' into lesson_07
Cogbonnia Oct 11, 2024
e332de5
Merge pull request #8 from Cogbonnia/lesson_05
Cogbonnia Oct 11, 2024
fb66aca
Merge pull request #9 from Cogbonnia/lesson_06
Cogbonnia Oct 11, 2024
c3abfab
Merge pull request #10 from Cogbonnia/lesson_07
Cogbonnia Oct 11, 2024
3714dc9
Merge branch 'code-differently:main' into main
Cogbonnia Oct 11, 2024
1bf357e
Merge branch 'code-differently:main' into main
Cogbonnia Oct 14, 2024
2a73ca9
Update lesson7.ts (deleted notes and comments)
Cogbonnia Oct 14, 2024
a7191db
Merge branch 'code-differently:main' into main
Cogbonnia Oct 14, 2024
8711f27
Merge branch 'code-differently:main' into main
Cogbonnia Oct 14, 2024
dadc906
Merge branch 'code-differently:main' into main
Cogbonnia Oct 14, 2024
eb5e90a
feat: added JSON file and DataProvider file for Chelsea
Cogbonnia Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lesson_05/quiz/src/lesson5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Lesson5 {
[AnswerChoice.C, "To insert an image"],
[AnswerChoice.D, "To create a paragraph"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -52,7 +52,7 @@ export class Lesson5 {
[AnswerChoice.C, "alt"],
[AnswerChoice.D, "href"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.C,
);
}

Expand All @@ -66,7 +66,7 @@ export class Lesson5 {
[AnswerChoice.C, "<div>"],
[AnswerChoice.D, "<link>"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -80,7 +80,7 @@ export class Lesson5 {
[AnswerChoice.C, "<span>"],
[AnswerChoice.D, "<br>"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -94,7 +94,7 @@ export class Lesson5 {
[AnswerChoice.C, "Computer Style Sheets"],
[AnswerChoice.D, "Cascading System Sheets"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -108,7 +108,7 @@ export class Lesson5 {
[AnswerChoice.C, "text-color"],
[AnswerChoice.D, "background-color"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -122,7 +122,7 @@ export class Lesson5 {
[AnswerChoice.C, "/* this is a comment */"],
[AnswerChoice.D, "<!-- this is a comment -->"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.C,
);
}

Expand All @@ -136,7 +136,7 @@ export class Lesson5 {
[AnswerChoice.C, "text-size"],
[AnswerChoice.D, "text-style"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -150,7 +150,7 @@ export class Lesson5 {
[AnswerChoice.C, "inline-block"],
[AnswerChoice.D, "none"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.B,
);
}

Expand All @@ -164,7 +164,7 @@ export class Lesson5 {
[AnswerChoice.C, "<stylesheet link='styles.css'>"],
[AnswerChoice.D, "<css href='styles.css'>"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice.A,
);
}
}
Expand Down
15 changes: 13 additions & 2 deletions lesson_06/expression/src/expression_calculator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
export class ExpressionCalculator {
/** Returns the calculation of ((a + b) * c) / d^e */
calculate(a: number, b: number, c: number, d: number, e: number): number {
// Implement your code here to return the correct value.
return 0;
return this.divide(this.multiply(this.add(a, b), c), this.pow(d, e));
}

add(a: number, b: number): number {
return a + b;
}

multiply(value: number, c: number): number {
return value * c;
}

divide(value: number, d: number): number {
return value / d;
}

pow(base: number, exponent: number): number {
Expand Down
72 changes: 62 additions & 10 deletions lesson_07/conditionals/src/lesson7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { computeLexicographicDistance } from "./util.js";
* @return True if the age corresponds to a voting age and false otherwise.
*/
export function canVote(age: number): boolean {
if (age >= 18) {
return true;
}
return false;
}

Expand All @@ -22,9 +25,13 @@ export function compareStrings(a: string, b: string): number {
// if it is greater, and 0 if the strings are equal.
const distance = computeLexicographicDistance(a, b);

// TODO(you): Finish this method.

return 0;
if (distance < 0) {
return -1;
} else if (distance > 0) {
return 1;
} else {
return 0;
}
}

/**
Expand All @@ -37,7 +44,29 @@ export function compareStrings(a: string, b: string): number {
* @return The letter grade ("A+", "A", "A-", "B+", etc.).
*/
export function convertGpaToLetterGrade(gpa: number): string {
return "F";
if (gpa == 4.0) {
return "A";
} else if (gpa <= 3.99 && gpa >= 3.7) {
return "A-";
} else if (gpa <= 3.69 && gpa >= 3.3) {
return "B+";
} else if (gpa <= 3.29 && gpa >= 3.0) {
return "B";
} else if (gpa <= 2.99 && gpa >= 2.7) {
return "B-";
} else if (gpa <= 2.69 && gpa >= 2.3) {
return "C+";
} else if (gpa <= 2.29 && gpa >= 2.0) {
return "C";
} else if (gpa <= 1.99 && gpa >= 1.7) {
return "C-";
} else if (gpa <= 1.69 && gpa >= 1.3) {
return "D+";
} else if (gpa <= 1.29 && gpa >= 1.0) {
return "D";
} else {
return "F";
}
}

/**
Expand All @@ -47,17 +76,25 @@ export function convertGpaToLetterGrade(gpa: number): string {
* @return The factorial of n.
*/
export function computeFactorial(n: number): number {
return 0;
if (n == 0 || n == 1) {
return 1;
} else if (n > 1) {
return n * computeFactorial(n - 1);
}
return n;
}

/**
* Adds all of the provided values and returns the sum.
*
* @param values The values to sum.
* @return The sum of all the values.
*/
export function addNumbers(values: number[]): number {
return 0;
let sum = 0;
for (const value of values) {
sum += value;
}
return sum;
}

/**
Expand All @@ -67,7 +104,17 @@ export function addNumbers(values: number[]): number {
* @return An array containing the first `n` Fibonacci values.
*/
export function getFirstNFibonacciNumbers(n: number): number[] {
return [];
const fibArray: number[] = [];
let a = 0;
let b = 1;
let c: number;
while (fibArray.length < n) {
c = a;
a = b;
b = c + b;
fibArray.push(a);
}
return fibArray;
}

/**
Expand All @@ -92,11 +139,16 @@ export function binarySearch(

const pivotIndex = Math.floor((start + end) / 2); // The index in the middle of the array.

// TODO(you): Finish implementing this algorithm

if (values[pivotIndex] == value) {
return pivotIndex;
} else if (values[pivotIndex] > value) {
return binarySearch(values, start, pivotIndex - 1, value);
} else {
return binarySearch(values, pivotIndex + 1, end, value);
}
// If values[pivotIndex] is equal to value then return `pivotIndex`.
// Else if values[pivotIndex] is greater than the value, then
// call `binarySearch(values, start, pivotIndex - 1, value)` and return its value;
// Else call `binarySearch(values, pivotIndex + 1, end, value)` and return its value.
return -1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.codedifferently.lesson9.dataprovider;

import java.util.Map;

import org.springframework.stereotype.Service;

@Service
public class ChelseaOgbonniaProvider extends DataProvider {
public String getProviderName() {
return "chelseaogbonnia";
}

public Map<String, Class> getColumnTypeByName() {
return Map.of(
"column1", Boolean.class,
"column2", String.class,
"column3", Long.class,
"column4", Float.class,
"column5", Short.class,
"column6", Double.class,
"column7", Integer.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[
{
"column1": "false",
"column2": "wyemiqc",
"column3": "7913473030711282688",
"column4": "1.8614628E38",
"column5": "4386",
"column6": "6.968862241086341E307",
"column7": "1475052651"
},
{
"column1": "false",
"column2": "xm6vs7e",
"column3": "2335425424589573632",
"column4": "4.2762104E37",
"column5": "1683",
"column6": "1.811140849460334E307",
"column7": "1209195687"
},
{
"column1": "true",
"column2": "zh01i84uv",
"column3": "6333972535042200576",
"column4": "2.2556577E38",
"column5": "2844",
"column6": "1.6951022043654575E308",
"column7": "1523085775"
},
{
"column1": "false",
"column2": "361pv72",
"column3": "3157565259847647232",
"column4": "2.3323055E38",
"column5": "10658",
"column6": "6.925332576553183E307",
"column7": "606901330"
},
{
"column1": "true",
"column2": "3sozwb",
"column3": "7571759049801341952",
"column4": "1.7445115E38",
"column5": "32321",
"column6": "1.5048343678097422E308",
"column7": "729461454"
},
{
"column1": "true",
"column2": "kpvif5ytmu6",
"column3": "9219750046175507456",
"column4": "1.8554071E37",
"column5": "3907",
"column6": "3.810850952045744E307",
"column7": "1877455265"
},
{
"column1": "false",
"column2": "mx0o5f",
"column3": "5732669568390959104",
"column4": "3.3571546E38",
"column5": "11344",
"column6": "1.5791425600565364E306",
"column7": "1198521383"
},
{
"column1": "false",
"column2": "ic8xp",
"column3": "8058294991460725760",
"column4": "1.0623648E38",
"column5": "19537",
"column6": "7.168009014976832E307",
"column7": "806176461"
},
{
"column1": "true",
"column2": "jh6513fuz",
"column3": "3050298536833992192",
"column4": "3.0041338E38",
"column5": "14100",
"column6": "1.347984905078725E308",
"column7": "552869949"
},
{
"column1": "true",
"column2": "p0tfc9w462",
"column3": "6108650764181306368",
"column4": "3.0027475E38",
"column5": "4463",
"column6": "9.346588542924494E306",
"column7": "20872235"
}
]
Loading