Skip to content

Glasgow | May-2025 | Salah Ahmed| Sprint-3 #634

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

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
41faaac
have done my key-implement exercise
Millena28 Feb 21, 2025
fb392b3
done the mandatory-rewrite
Millena28 Feb 21, 2025
52148a6
Done the mandatory-practice
Millena28 Feb 27, 2025
4d0497e
Done stretch investigate and implemented new card-validator file
Millena28 Feb 28, 2025
13220cd
done ALL
Millena28 Feb 28, 2025
396094b
made some corrections from review
Millena28 Mar 18, 2025
f3b70e8
Merge branch 'CodeYourFuture:coursework/sprint-3' into coursework/spr…
avatarit Jun 28, 2025
8ca4e8e
Implement angle type identification in getAngleType function
avatarit Jun 28, 2025
a9c9341
Remove placeholder comments for missing tests in getAngleType function
avatarit Jun 28, 2025
b1b2078
Refactor getAngleType function for improved readability and consistency
avatarit Jun 28, 2025
78e3a52
Add assertions for zero numerator check in isProperFraction function
avatarit Jun 28, 2025
c75235c
Fix formatting inconsistencies in angle type assertions for clarity
avatarit Jun 28, 2025
39aad2d
Refactor getCardValue function to improve card rank extraction and va…
avatarit Jun 28, 2025
0d2e786
Refactor getAngleType function to streamline angle classification logic
avatarit Jul 2, 2025
ef3385f
Refactor getCardValue function for improved clarity and error handling
avatarit Jul 2, 2025
f381483
Update package-lock.json to reflect changes in package names and vers…
avatarit Jul 2, 2025
49bcbfe
Refactor isProperFraction function and update tests for accuracy
avatarit Jul 2, 2025
5774458
Remove unnecessary files: package.json, readme.md, and image assets
avatarit Jul 2, 2025
9226863
Add tests for getCardValue function to validate card value retrieval …
avatarit Jul 2, 2025
e8bdd72
Add getCardValue function to retrieve card values with error handling
avatarit Jul 2, 2025
03fd47d
Add tests for getAngleType function to validate angle identification
avatarit Jul 2, 2025
61cdb3e
Implement getAngleType function with angle classification and corresp…
avatarit Jul 2, 2025
41d94fc
Implement isProperFraction function with comprehensive test cases
avatarit Jul 2, 2025
0f70f77
Implement isProperFraction function to evaluate proper fractions
avatarit Jul 2, 2025
830b5e4
Refactor code structure for improved readability and maintainability
avatarit Jul 2, 2025
b500e15
Fix the code of get angle
avatarit Jul 2, 2025
e931299
Remove unnecessary blank line in isProperFraction.js
avatarit Jul 2, 2025
315ab1a
fixed the code issue
avatarit Jul 2, 2025
aae7d84
Remove unnecessary blank line at the beginning of get-card-value.js
avatarit Jul 2, 2025
2fd86de
Refactor angle type function to improve clarity and return default va…
avatarit Jul 2, 2025
c693e17
Refactor angle type tests for clarity by removing redundant comments
avatarit Jul 2, 2025
4330f25
fix the issue in the code
avatarit Jul 2, 2025
d92d35c
Update isProperFraction test file
avatarit Jul 2, 2025
c45f222
Refactor getCardValue function for improved readability by adjusting …
avatarit Jul 2, 2025
388622f
Refactor test cases for getCardValue function by reorganizing comment…
avatarit Jul 2, 2025
51997e1
Update countChar function
avatarit Jul 2, 2025
88e292d
Fix formatting of comment in count.test.js for consistency
avatarit Jul 2, 2025
7829d7e
Refactor getOrdinalNumber function for improved readability by adjust…
avatarit Jul 2, 2025
e924d5d
update ordinal-number.test.js for improved readability
avatarit Jul 2, 2025
475029a
Fix formatting
avatarit Jul 2, 2025
65bcde5
implement the code
avatarit Jul 2, 2025
fef80b8
Refactor isValidCreditCard function for improved readability and cons…
avatarit Jul 3, 2025
9549f29
The questions have been answerd
avatarit Jul 3, 2025
97d365f
fix passwordValidator function
avatarit Jul 3, 2025
35c9171
update the file
avatarit Jul 3, 2025
5677d8b
Refactor angle type identification tests for clarity and consistency;…
avatarit Jul 13, 2025
ec1de20
Refactor isProperFraction function for improved logic and to handle z…
avatarit Jul 13, 2025
11f25a5
Fix invalid card rank test case variable name for consistency
avatarit Jul 13, 2025
a9d379c
Add test case for handling unknown angles in angle type identification
avatarit Jul 13, 2025
d2b2de9
Refactor isProperFraction function for improved logic and update test…
avatarit Jul 13, 2025
c571045
Add tests for negative numbers, non-integer inputs, and zero in getOr…
avatarit Jul 13, 2025
4f777e0
Implement repeat function with input validation and update tests for …
avatarit Jul 14, 2025
749afc7
Remove redundant Ace test cases for different suits in getCardValue t…
avatarit Jul 14, 2025
5ff8087
Refactor password validator and update tests for clarity and accuracy
avatarit Jul 14, 2025
dc7f375
Fix error message for negative count in repeat function and update co…
avatarit Jul 14, 2025
2c6495f
Fixed the issues
avatarit Jul 18, 2025
508e086
Delete package.json
avatarit Jul 18, 2025
c38f34c
Fixed the comments
avatarit Jul 19, 2025
6d0daca
json file
avatarit Jul 19, 2025
b657e8d
fix: restore package files to match base branch
avatarit Jul 19, 2025
4e1cb4a
Removes trailing newline from extensions configuration
avatarit Jul 20, 2025
22bc718
remove json files from PR
avatarit Jul 20, 2025
9d595c7
Merge branch 'CodeYourFuture:main' into coursework/sprint-3
avatarit Jul 20, 2025
5477c7a
Delete .github/FUNDING.yml
avatarit Jul 20, 2025
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
11 changes: 0 additions & 11 deletions .vscode/extensions.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this file from your PR? It may have been added by mistake. Once your PR has been created, it's a good habit to review the files and ensure that only the required files are included! :)

This file was deleted.

35 changes: 25 additions & 10 deletions Sprint-3/1-key-implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@

// Implement a function getAngleType
// Build up your function case by case, writing tests as you go
// The first test and case is written for you. The next case has a test, but no code.
// Execute this script in your terminal
// node 1-get-angle-type.js
//node 1-get-angle-type.js
// The assertion error will tell you what the expected output is
// Write the code to pass the test
// Then, write the next test! :) Go through this process until all the cases are implemented

function getAngleType(angle) {
if (angle === 90) return "Right angle";
if (angle === 90) return "Right angle";
if (angle > 0 && angle < 90) return "Acute angle";
if (angle > 90 && angle < 180) return "Obtuse angle";
if (angle === 180) return "Straight angle";
if (angle > 180 && angle < 360) return "Reflex angle";
// If the angle is not in any of the above categories, we can return a default value
return "Unknown angle type";
// read to the end, complete line 36, then pass your test here
}

Expand All @@ -30,27 +37,35 @@ function assertEquals(actualOutput, targetOutput) {
// Case 1: Identify Right Angles:
// When the angle is exactly 90 degrees,
// Then the function should return "Right angle"
const right = getAngleType(90);
assertEquals(right, "Right angle");
const rightAngle = getAngleType(90);
assertEquals(rightAngle, "Right angle");

// Case 2: Identify Acute Angles:
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
const acute = getAngleType(45);
assertEquals(acute, "Acute angle");
const acuteAngle = getAngleType(45);
assertEquals(acuteAngle, "Acute angle");

// Case 3: Identify Obtuse Angles:
// When the angle is greater than 90 degrees and less than 180 degrees,
// Then the function should return "Obtuse angle"
const obtuse = getAngleType(120);
// ====> write your test here, and then add a line to pass the test in the function above
const obtuseAngle = getAngleType(120);
assertEquals(obtuseAngle,"Obtuse angle");

// Case 4: Identify Straight Angles:
// When the angle is exactly 180 degrees,
// Then the function should return "Straight angle"
// ====> write your test here, and then add a line to pass the test in the function above
const straightAngle = getAngleType(180);
assertEquals(straightAngle,"Straight angle");

// Case 5: Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
// ====> write your test here, and then add a line to pass the test in the function above
const reflexAngle = getAngleType(200);
assertEquals(reflexAngle,"Reflex angle");

// Case 6: Handle Unknown Angles:
// When the angle is not in any of the above categories (e.g., negative angles or angles greater than or equal to 360 degrees),
// Then the function should return "Unknown angle type"
const unknownAngle = getAngleType(400);
assertEquals(unknownAngle, "Unknown angle type");
14 changes: 10 additions & 4 deletions Sprint-3/1-key-implement/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
return Math.abs(numerator)< Math.abs(denominator) && denominator !== 0;

}

// here's our helper again
Expand All @@ -20,7 +21,6 @@ function assertEquals(actualOutput, targetOutput) {
}

// Acceptance criteria:

// Proper Fraction check:
// Input: numerator = 2, denominator = 3
// target output: true
Expand All @@ -40,14 +40,20 @@ assertEquals(improperFraction, false);
// target output: true
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
const negativeFraction = isProperFraction(-4, 7);
// ====> complete with your assertion
assertEquals(negativeFraction,true);

// Equal Numerator and Denominator check:
// Input: numerator = 3, denominator = 3
// target output: false
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
const equalFraction = isProperFraction(3, 3);
// ====> complete with your assertion
assertEquals(improperFraction,false);

// Stretch:
// What other scenarios could you test for?
// Zero Numerator check:
// Input: numerator = 0, denominator = 5
// target output: true
// Explanation: The fraction 0/5 is a proper fraction because the numerator is zero, which is less than the denominator. The function should return true.
const zeroNumerator = isProperFraction(0, 5);
assertEquals(zeroNumerator, true);
34 changes: 25 additions & 9 deletions Sprint-3/1-key-implement/3-get-card-value.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// This problem involves playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck

// You will need to implement a function getCardValue
// the function takes a single parameter, a string representing a playing card
// the function should return the numerical value of the card
Expand All @@ -8,20 +7,30 @@
// write one test at a time, and make it pass, build your solution up methodically
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {
if (rank === "A") return 11;
}
if (!card || typeof card !== "string") return "Invalid card format";
//extracting the rank of the card
const rank = card.slice(0, -1);

//parseInt(rank) and Number(rank) are the same thing. parseInt() is a function that parses a string and returns an integer. If the first character in the string can't be converted into a number, then it returns NaN. Number() is a function that converts a string to a number. If the string can't be converted into a number, then it returns NaN.
if (rank === "A") return 11;
//For numerical cards, we return the number
else if (Number(rank) >= 2 && Number(rank) <= 10) return Number(rank);
//For face cards, we return 10
else if ( rank === "J" || rank=== "Q" || rank ==="K" ) return 10;
//If the card is invalid, we throw an error
else return("Invalid card rank.");
}

// You need to write assertions for your function to check it works in different cases
// we're going to use this helper function to make our assertions easier to read
// if the actual output matches the target output, the test will pass
function assertEquals(actualOutput, targetOutput) {
console.assert(
actualOutput === targetOutput,
`Expected ${actualOutput} to equal ${targetOutput}`
);
console.assert(
actualOutput === targetOutput,
`Expected ${actualOutput} to equal ${targetOutput}`
);
}
// Acceptance criteria:

// Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A),
// When the function getCardValue is called with this card string as input,
// Then it should return the numerical card value
Expand All @@ -33,19 +42,26 @@ assertEquals(aceofSpades, 11);
// When the function is called with such a card,
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5).
const fiveofHearts = getCardValue("5♥");
// ====> write your test here, and then add a line to pass the test in the function above
assertEquals(fiveofHearts,5);

// Handle Face Cards (J, Q, K):
// Given a card with a rank of "10," "J," "Q," or "K",
// When the function is called with such a card,
// Then it should return the value 10, as these cards are worth 10 points each in blackjack.
assertEquals(getCardValue("J♣"), 10);
assertEquals(getCardValue("Q♦"), 10);
assertEquals(getCardValue("K♠"), 10);

// Handle Ace (A):
// Given a card with a rank of "A",
// When the function is called with an Ace,
// Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack.
const aceofDiamonds = getCardValue("A♠");
assertEquals(aceofDiamonds, 11);

// Handle Invalid Cards:
// Given a card with an invalid rank (neither a number nor a recognized face card),
// When the function is called with such a card,
// Then it should throw an error indicating "Invalid card rank."
const invalidRank = getCardValue("1♦");
assertEquals(invalidRank,"Invalid card rank.");
16 changes: 8 additions & 8 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
function getAngleType(angle) {
if (angle === 90) return "Right angle";
// replace with your completed function from key-implement

if (angle > 0 && angle < 90) return "Acute angle";
if (angle > 90 && angle < 180) return "Obtuse angle";
if (angle === 180) return "Straight angle";
if (angle > 180 && angle < 360) return "Reflex angle";
// If the angle is not in any of the above categories, we can return a default value
return "Unknown angle type";
// read to the end, complete line 36, then pass your test here
}






module.exports = getAngleType;


// Don't get bogged down in this detail
Expand Down
33 changes: 33 additions & 0 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good set of tests. I would recommend adding a test for "Unknown angle type" since this is a part of your getAngleType function.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,48 @@ test("should identify right angle (90°)", () => {
// Case 2: Identify Acute Angles:
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
test("should identify acute angles (less than 90°)", () => {
expect(getAngleType(45)).toEqual("Acute angle");
expect(getAngleType(1)).toEqual("Acute angle");
expect(getAngleType(89)).toEqual("Acute angle");
});



// Case 3: Identify Obtuse Angles:
// When the angle is greater than 90 degrees and less than 180 degrees,
// Then the function should return "Obtuse angle"
test("should identify obtuse angles (between 90° and 180°)", () => {
expect(getAngleType(120)).toEqual("Obtuse angle");
expect(getAngleType(91)).toEqual("Obtuse angle");
expect(getAngleType(179)).toEqual("Obtuse angle");
});


// Case 4: Identify Straight Angles:
// When the angle is exactly 180 degrees,
// Then the function should return "Straight angle"
test("should identify straight angle (180°)", () => {
expect(getAngleType(180)).toEqual("Straight angle");
});



// Case 5: Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
test("should identify reflex angles (between 180° and 360°)", () => {
expect(getAngleType(270)).toEqual("Reflex angle");
expect(getAngleType(181)).toEqual("Reflex angle");
expect(getAngleType(359)).toEqual("Reflex angle");
});


// Case 6: Handle Unknown Angles:
// When the angle is not in any of the above categories (e.g., negative angles or angles greater than or equal to 360 degrees),
// Then the function should return "Unknown angle type"
test("should handle unknown angles (negative or >= 360°)", () => {
expect(getAngleType(-45)).toEqual("Unknown angle type");
expect(getAngleType(360)).toEqual("Unknown angle type");
expect(getAngleType(400)).toEqual("Unknown angle type");
});
3 changes: 2 additions & 1 deletion Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
return Math.abs(numerator) < Math.abs(denominator) && denominator !== 0;

// add your completed function from key-implement here
}

Expand Down
52 changes: 49 additions & 3 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,57 @@
const isProperFraction = require("./2-is-proper-fraction");

// Test cases for isProperFraction function
// Case 1: Identify Proper Fractions:
// When the numerator is less than the denominator,
// Then the function should return true indicating a proper fraction.
test("should return true for a proper fraction", () => {
expect(isProperFraction(2, 3)).toEqual(true);
});

// Case 2: Identify Improper Fractions:
test("should return false for an improper fraction", () => {
expect(isProperFraction(5, 2)).toEqual(false);
});

// Case 3: Identify Negative Fractions:
// Case 2: Identify Zero Numerator:
test("should return true for a zero numerator", () => {
expect(isProperFraction(0, 5)).toEqual(true);
});

// Case 4: Identify Equal Numerator and Denominator:
// Case 3: Identify Negative proper Fractions:

test("should return false for a negative improper fraction", () => {
expect(isProperFraction(-3, -4)).toEqual(true);
});

// Case 4: Identify Negative Improper Fractions:
test("should return true for a negative proper fraction", () => {
expect(isProperFraction(-5, -3)).toEqual(false);
});

// Case 5: Identify Equal Numerator and Denominator:
test("should return false for equal numerator and denominator", () => {
expect(isProperFraction(5,5)).toEqual(false);
});

// Case 6: Identify Zero Denominator:
test("should return false for zero denominator", () => {
expect(isProperFraction(5, 0)).toEqual(false);
});

// Case 7: Identify Negative Denominator:
test("should return true for a negative denominator", () => {
expect(isProperFraction(3, -4)).toEqual(true);
});

// Case 8: invalid input:
test("should return false for invalid input", () => {
expect(isProperFraction("a", 3)).toEqual(false);
expect(isProperFraction(2, "b")).toEqual(false);
expect(isProperFraction("c", "d")).toEqual(false);
});

// Case 9: empty input:
test("should return false for empty input", () => {
expect(isProperFraction()).toEqual(false);
expect(isProperFraction("", "")).toEqual(false);
});
18 changes: 15 additions & 3 deletions Sprint-3/2-mandatory-rewrite/3-get-card-value.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@

function getCardValue(card) {
// replace with your code from key-implement
return 11;
}
if (!card || typeof card !== "string") return "Invalid card format";
//extracting the rank of the card
const rank = card.slice(0, -1);

//parseInt(rank) and Number(rank) are the same thing. parseInt() is a function that parses a string and returns an integer. If the first character in the string can't be converted into a number, then it returns NaN. Number() is a function that converts a string to a number. If the string can't be converted into a number, then it returns NaN.
if (rank === "A") return 11;
//For numerical cards, we return the number
else if (Number(rank) >= 2 && Number(rank) <= 10) return Number(rank);
//For face cards, we return 10
else if ( rank === "J" || rank=== "Q" || rank ==="K" ) return 10;
//If the card is invalid, we throw an error
else return("Invalid card rank.");
}

module.exports = getCardValue;
Loading