From c57bb27b99388b2ba2f3aa11f67dd2894fc64370 Mon Sep 17 00:00:00 2001 From: Cogbonnia <244cogbonnia@gmail.com> Date: Sat, 5 Oct 2024 22:19:50 +0000 Subject: [PATCH 1/5] Update lesson_05 --- lesson_05/quiz/src/lesson5.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lesson_05/quiz/src/lesson5.ts b/lesson_05/quiz/src/lesson5.ts index 9ad62bd67..74ec75628 100644 --- a/lesson_05/quiz/src/lesson5.ts +++ b/lesson_05/quiz/src/lesson5.ts @@ -38,7 +38,7 @@ export class Lesson5 { [AnswerChoice.C, "To insert an image"], [AnswerChoice.D, "To create a paragraph"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -52,7 +52,7 @@ export class Lesson5 { [AnswerChoice.C, "alt"], [AnswerChoice.D, "href"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.C, ); } @@ -66,7 +66,7 @@ export class Lesson5 { [AnswerChoice.C, "
"], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -80,7 +80,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, "
"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -94,7 +94,7 @@ export class Lesson5 { [AnswerChoice.C, "Computer Style Sheets"], [AnswerChoice.D, "Cascading System Sheets"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -108,7 +108,7 @@ export class Lesson5 { [AnswerChoice.C, "text-color"], [AnswerChoice.D, "background-color"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -122,7 +122,7 @@ export class Lesson5 { [AnswerChoice.C, "/* this is a comment */"], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.C, ); } @@ -136,7 +136,7 @@ export class Lesson5 { [AnswerChoice.C, "text-size"], [AnswerChoice.D, "text-style"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -150,7 +150,7 @@ export class Lesson5 { [AnswerChoice.C, "inline-block"], [AnswerChoice.D, "none"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -164,7 +164,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.A, ); } } From 5cc0b8511fc2e9a8e0069edcf0215c220887f145 Mon Sep 17 00:00:00 2001 From: Cogbonnia <244cogbonnia@gmail.com> Date: Wed, 9 Oct 2024 15:03:32 +0000 Subject: [PATCH 2/5] Lesson 06: Completed --- lesson_06/expression/src/expression_calculator.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 13cb2ca05..f63348dad 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -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 { From 72adf4181c7db6fab0e2b2a39160e271a2f8c05f Mon Sep 17 00:00:00 2001 From: Cogobonnia <244cogbonnia@gmail.com> Date: Fri, 11 Oct 2024 13:10:10 +0000 Subject: [PATCH 3/5] fix: completed the functions --- lesson_07/conditionals/src/lesson7.ts | 71 ++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/lesson_07/conditionals/src/lesson7.ts b/lesson_07/conditionals/src/lesson7.ts index 52f45df8b..58fd001b2 100644 --- a/lesson_07/conditionals/src/lesson7.ts +++ b/lesson_07/conditionals/src/lesson7.ts @@ -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; } @@ -22,9 +25,14 @@ export function compareStrings(a: string, b: string): number { // if it is greater, and 0 if the strings are equal. const distance = computeLexicographicDistance(a, b); + if (distance < 0) { + return -1; + } else if (distance > 0) { + return 1; + } else { + return 0; + } // TODO(you): Finish this method. - - return 0; } /** @@ -37,7 +45,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"; + } } /** @@ -47,9 +77,14 @@ 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; } - +/* 4! = 4 x 3 x 2 x 1 = 24*/ /** * Adds all of the provided values and returns the sum. * @@ -57,7 +92,11 @@ export function computeFactorial(n: number): number { * @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; } /** @@ -67,7 +106,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; } /** @@ -94,9 +143,15 @@ export function binarySearch( // 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; } From 2a73ca99e41eec463dbb259414de24bfd6baf663 Mon Sep 17 00:00:00 2001 From: Cogbonnia <244cogbonnia@gmail.com> Date: Mon, 14 Oct 2024 08:49:39 -0400 Subject: [PATCH 4/5] Update lesson7.ts (deleted notes and comments) --- lesson_07/conditionals/src/lesson7.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/lesson_07/conditionals/src/lesson7.ts b/lesson_07/conditionals/src/lesson7.ts index 58fd001b2..3f720b6f1 100644 --- a/lesson_07/conditionals/src/lesson7.ts +++ b/lesson_07/conditionals/src/lesson7.ts @@ -32,7 +32,6 @@ export function compareStrings(a: string, b: string): number { } else { return 0; } - // TODO(you): Finish this method. } /** @@ -84,7 +83,6 @@ export function computeFactorial(n: number): number { } return n; } -/* 4! = 4 x 3 x 2 x 1 = 24*/ /** * Adds all of the provided values and returns the sum. * @@ -141,7 +139,6 @@ 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; From eb5e90a137d3ba51c45967a905e1a5eaf65d15dc Mon Sep 17 00:00:00 2001 From: Cogobonnia <244cogbonnia@gmail.com> Date: Tue, 15 Oct 2024 14:36:55 +0000 Subject: [PATCH 5/5] feat: added JSON file and DataProvider file for Chelsea --- .../dataprovider/ChelseaOgbonniaProvider.java | 23 +++++ .../main/resources/data/chelseaogbonnia.json | 92 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/ChelseaOgbonniaProvider.java create mode 100644 lesson_09/types/types_app/src/main/resources/data/chelseaogbonnia.json diff --git a/lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/ChelseaOgbonniaProvider.java b/lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/ChelseaOgbonniaProvider.java new file mode 100644 index 000000000..c2aaf23d0 --- /dev/null +++ b/lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/ChelseaOgbonniaProvider.java @@ -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 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); + } +} diff --git a/lesson_09/types/types_app/src/main/resources/data/chelseaogbonnia.json b/lesson_09/types/types_app/src/main/resources/data/chelseaogbonnia.json new file mode 100644 index 000000000..8938e7388 --- /dev/null +++ b/lesson_09/types/types_app/src/main/resources/data/chelseaogbonnia.json @@ -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" + } +] \ No newline at end of file