Skip to content

Emin Akturk| West Midlands| MAY | Module-Structuring-data| Coursework-Sprint3 #692

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 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
84e3bca
First 3 exercises of sprint 1 are completed.
eminakturk Jun 25, 2025
3c9fb3a
Key exercise part is done with this commit
eminakturk Jun 25, 2025
c882576
Mandatory errors 0 and 1.js is solved.
eminakturk Jun 25, 2025
8ccf3b2
Mandatory-errors part is finished.
eminakturk Jun 25, 2025
d0c0bd7
until time format is finished.
eminakturk Jun 27, 2025
721fe57
finishing touch
eminakturk Jun 27, 2025
3eff2ca
get-angle-type is sorted.
eminakturk Jul 27, 2025
0de42f1
proper fraction sorted.
eminakturk Jul 27, 2025
5d8d05c
get card value sorted.
eminakturk Jul 27, 2025
7fe2790
sprint3 coursework done.
eminakturk Jul 27, 2025
fed3a0c
Merge branch 'main' into coursework/sprint3
eminakturk Jul 27, 2025
16e88b9
Delete Sprint-1/1-key-exercises/1-count.js
eminakturk Aug 4, 2025
17f9a99
Delete Sprint-1/1-key-exercises/2-initials.js
eminakturk Aug 4, 2025
4266d77
Delete Sprint-1/1-key-exercises/3-paths.js
eminakturk Aug 4, 2025
05564df
Delete Sprint-1/1-key-exercises/4-random.js
eminakturk Aug 4, 2025
a932cb1
Delete Sprint-1/2-mandatory-errors/0.js
eminakturk Aug 4, 2025
2c47ed9
Delete Sprint-1/2-mandatory-errors/1.js
eminakturk Aug 4, 2025
1b7c8c7
Delete Sprint-1/2-mandatory-errors/2.js
eminakturk Aug 4, 2025
c95381e
Delete Sprint-1/2-mandatory-errors/3.js
eminakturk Aug 4, 2025
1fd0b02
Delete Sprint-1/2-mandatory-errors/4.js
eminakturk Aug 4, 2025
71b7003
Delete Sprint-1/3-mandatory-interpret/1-percentage-change.js
eminakturk Aug 4, 2025
0c7b105
Delete Sprint-1/3-mandatory-interpret/2-time-format.js
eminakturk Aug 4, 2025
97d27ed
Delete Sprint-1/3-mandatory-interpret/3-to-pounds.js
eminakturk Aug 4, 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
6 changes: 0 additions & 6 deletions Sprint-1/1-key-exercises/1-count.js

This file was deleted.

11 changes: 0 additions & 11 deletions Sprint-1/1-key-exercises/2-initials.js

This file was deleted.

23 changes: 0 additions & 23 deletions Sprint-1/1-key-exercises/3-paths.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sprint-1/1-key-exercises/4-random.js

This file was deleted.

2 changes: 0 additions & 2 deletions Sprint-1/2-mandatory-errors/0.js

This file was deleted.

4 changes: 0 additions & 4 deletions Sprint-1/2-mandatory-errors/1.js

This file was deleted.

5 changes: 0 additions & 5 deletions Sprint-1/2-mandatory-errors/2.js

This file was deleted.

9 changes: 0 additions & 9 deletions Sprint-1/2-mandatory-errors/3.js

This file was deleted.

2 changes: 0 additions & 2 deletions Sprint-1/2-mandatory-errors/4.js

This file was deleted.

22 changes: 0 additions & 22 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js

This file was deleted.

25 changes: 0 additions & 25 deletions Sprint-1/3-mandatory-interpret/2-time-format.js

This file was deleted.

27 changes: 0 additions & 27 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js

This file was deleted.

15 changes: 11 additions & 4 deletions Sprint-3/1-key-implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
// 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 < 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";
// read to the end, complete line 36, then pass your test here
}

Expand Down Expand Up @@ -44,13 +48,16 @@ assertEquals(acute, "Acute angle");
// 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

assertEquals(obtuse, "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 straight = getAngleType(180);
assertEquals(straight, "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
// ====> write your test here, and then add a line to pass the test in the function above
const reflex = getAngleType(270);
assertEquals(reflex, "Reflex angle");
14 changes: 9 additions & 5 deletions Sprint-3/1-key-implement/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
if (Math.abs(numerator) < Math.abs(denominator)) {
return true;
} else {
return false;
}
}

// here's our helper again
function assertEquals(actualOutput, targetOutput) {
console.assert(
actualOutput === targetOutput,
`Expected ${actualOutput} to equal ${targetOutput}`
Expected ${actualOutput} to equal ${targetOutput}
);
}

Expand All @@ -40,14 +44,14 @@ 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(equalFraction, false);

// Stretch:
// What other scenarios could you test for?
// What other scenarios could you test for?
23 changes: 22 additions & 1 deletion Sprint-3/1-key-implement/3-get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
// 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) {
const rank = card.slice(0, -1);
if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10;
if (!isNaN(rank)) return Number(rank);
throw new Error("Invalid card rank.");
}

// You need to write assertions for your function to check it works in different cases
Expand All @@ -33,12 +37,23 @@ 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.
const jackofClubs = getCardValue("J♣");
assertEquals(jackofClubs, 10);

const queenofDiamonds = getCardValue("Q♦");
assertEquals(queenofDiamonds, 10);

const kingofHearts = getCardValue("K♥");
assertEquals(kingofHearts, 10);

const tenofSpades = getCardValue("10♠");
assertEquals(tenofSpades, 10);

// Handle Ace (A):
// Given a card with a rank of "A",
Expand All @@ -49,3 +64,9 @@ const fiveofHearts = getCardValue("5♥");
// 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."
try {
getCardValue("Z♠");
console.error("Error was expected but not thrown");
} catch (e) {
assertEquals(e.message, "Invalid card rank.");
}
6 changes: 5 additions & 1 deletion Sprint-3/2-mandatory-rewrite/1-get-angle-type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
function getAngleType(angle) {
if (angle === 90) return "Right angle";
// replace with your completed function from key-implement
if (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";
}

}

Expand Down
16 changes: 10 additions & 6 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ test("should identify right angle (90°)", () => {
expect(getAngleType(90)).toEqual("Right angle");
});

// REPLACE the comments with the tests
// make your test descriptions as clear and readable as possible

// 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");
});

// 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 (greater than 90° and less than 180°)", () => {
expect(getAngleType(120)).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"
/
7 changes: 6 additions & 1 deletion Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
// add your completed function from key-implement here
if (Math.abs(numerator) < Math.abs(denominator)) {
return true;
} else {
return false;
}
}

module.exports = isProperFraction;
module.exports = isProperFraction;
9 changes: 9 additions & 0 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ test("should return true for a proper fraction", () => {
});

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

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

// Case 4: Identify Equal Numerator and Denominator:
test("should return false when numerator and denominator are equal", () => {
expect(isProperFraction(3, 3)).toEqual(false);
});
10 changes: 7 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,9 @@
function getCardValue(card) {
// replace with your code from key-implement
return 11;
const rank = card.slice(0, -1);
if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10;
if (!isNaN(rank)) return Number(rank);
throw new Error("Invalid card rank.");
}
module.exports = getCardValue;

module.exports = getCardValue;
19 changes: 18 additions & 1 deletion Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@ const getCardValue = require("./3-get-card-value");
test("should return 11 for Ace of Spades", () => {
const aceofSpades = getCardValue("A♠");
expect(aceofSpades).toEqual(11);
});
});

// Case 2: Handle Number Cards (2-10):
test("should return correct number for number cards", () => {
expect(getCardValue("5♥")).toEqual(5);
expect(getCardValue("10♦")).toEqual(10);
});

// Case 3: Handle Face Cards (J, Q, K):
test("should return 10 for face cards J, Q, K", () => {
expect(getCardValue("J♣")).toEqual(10);
expect(getCardValue("Q♦")).toEqual(10);
expect(getCardValue("K♥")).toEqual(10);
});

// Case 4: Handle Ace (A):
// (Already tested above with Ace of Spades)

// Case 5: Handle Invalid Cards:
test("should throw error for invalid cards", () => {
expect(() => getCardValue("Z♠")).toThrow("Invalid card rank.");
expect(() => getCardValue("1♠")).toThrow("Invalid card rank.");
});
Loading