generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 219
Sheffield|May-2025|Sheida Shabankari|Module-Structuring-and-Testing-Data | Sprint-3 #572
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
Closed
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
40adc65
Create sprint-1
sheida-shab c61fb0c
implementing function get angel
sheida-shab 71fa8a2
writing and passing test cases for angels
sheida-shab 89c7448
implementing function for proper fraction
sheida-shab 1082edb
writing and passing tests for proper fraction
sheida-shab d9a58aa
implementing function for card values
sheida-shab 44ed00b
writing and passing test cases for function card values
sheida-shab e8a7465
implementig and testing function with assert
sheida-shab 50a07af
Implement and assert function isProperFraction
sheida-shab d7b198c
implement and assert function getCardValue
sheida-shab ce6b980
more assertion and error catch
sheida-shab ab10b0b
update and improve function and test
sheida-shab 25e466c
updatin and catch error
sheida-shab 26d4e68
update function
sheida-shab b3c1079
implement and test function countChar
sheida-shab 0cd41c0
testing and implementing getOrdinalNumber function
sheida-shab d33ce93
Implement & test function repeat except error handling
sheida-shab 3084993
Implement function repeat and write test cases
sheida-shab 7f28d1a
play computer find function
sheida-shab 8a271db
write program Password Validation and test cases
sheida-shab 91de44d
Add more test case
sheida-shab 1c6712c
add some comments
sheida-shab 9f7a062
Add abs function
sheida-shab 8bb9053
change variable names
sheida-shab e1a7f32
check ["♠", "♥", "♦", "♣"] only once
sheida-shab fedcfaf
card’s rank matches exactly allowed numbers
sheida-shab f9c3394
fix the typo mistake
sheida-shab 38458ec
improve functions and use suggestions for better code
sheida-shab e9c214a
delete folder coursework/sprin1
sheida-shab 7800bb0
simplify the code
sheida-shab 68cf386
improve the function checking
sheida-shab c4261ec
manage 111 ordinal number
sheida-shab ea54b62
using else and else if
sheida-shab 2f429e6
grouping the tests in to 5 group
sheida-shab 652e6b6
change the answer of d question
sheida-shab 6055567
solving the error message
sheida-shab fcac4b6
improve the indentation
sheida-shab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
.vscode | ||
**/.DS_Store | ||
**/.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
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) return "Reflex angle"; | ||
|
||
// replace with your completed function from key-implement | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// Don't get bogged down in this detail | ||
// Jest uses CommonJS module syntax by default as it's quite old | ||
// We will upgrade our approach to ES6 modules in the next course module, so for now | ||
// We will upgrade our approach to ES6 modules in the next course module, so for now | ||
// we have just written the CommonJS module.exports syntax for you | ||
module.exports = getAngleType; | ||
module.exports = getAngleType; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
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; | ||
return false; | ||
} | ||
|
||
module.exports = isProperFraction; | ||
module.exports = isProperFraction; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
// replace with your code from key-implement | ||
let rank = card[0]; | ||
|
||
if (["♠", "♥", "♦", "♣"].includes(card.slice(-1))){ | ||
if (card.length > 2) { | ||
rank = card.slice(0, card.length - 1); | ||
} | ||
|
||
if (rank === "A") return 11; | ||
if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(rank)) | ||
return parseInt(rank); | ||
if ( ["J", "Q", "K"].includes(rank) ) | ||
return 10; | ||
} | ||
module.exports = getCardValue; | ||
throw new Error("Invalid card rank."); | ||
} | ||
module.exports = getCardValue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
const getCardValue = require("./3-get-card-value"); | ||
|
||
test("should return 11 for Ace of Spades", () => { | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
test("should return the number of the card for 2♥", () => { | ||
const numberCards = getCardValue("2♥"); | ||
expect(numberCards).toEqual(2); | ||
}); | ||
|
||
// Case 3: Handle Face Cards (J, Q, K): | ||
test("should return 10 for J♣", () => { | ||
const faceCards = getCardValue("J♣"); | ||
expect(faceCards).toEqual(10); | ||
}); | ||
|
||
// Case 4: Handle Ace (A): | ||
test("should return 11 for A♥", () => { | ||
const aceCards = getCardValue("A♥"); | ||
expect(aceCards).toEqual(11); | ||
}); | ||
// Case 5: Handle Invalid Cards: | ||
test("throws error on invalid card", () => { | ||
expect(() => getCardValue("223")).toThrow(Error.message); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
let count = 0; | ||
for (let i = 0; i <= stringOfCharacters.length - 1; i++) { | ||
if (stringOfCharacters[i] === findCharacter) { | ||
count++; | ||
} | ||
} | ||
return count; | ||
} | ||
|
||
module.exports = countChar; | ||
module.exports = countChar; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18
Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
let lastDigit = num.toString().slice(-1); | ||
let last2Digit = num.toString().slice(-2); | ||
let numToString = num.toString(); | ||
|
||
if (["11", "12", "13"].includes(last2Digit)) { | ||
return numToString + "th"; | ||
} else if (lastDigit === "1") { | ||
return numToString + "st"; | ||
} else if (lastDigit === "2") { | ||
return numToString + "nd"; | ||
} else if (lastDigit === "3") { | ||
return numToString + "rd"; | ||
} else { | ||
return numToString + "th"; | ||
} | ||
} | ||
|
||
module.exports = getOrdinalNumber; | ||
module.exports = getOrdinalNumber; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.