-
-
Notifications
You must be signed in to change notification settings - Fork 269
Sheffield | 25-ITP-Sep | Xiayidan Abuduxukuer | Sprint 3 | Coursework implement and rewrite #881
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests on this script is pretty solid. Have you tried running this script (after you made changes to the implementation of the function in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,45 @@ | |
| // We will use the same function, but write tests for it using Jest in this file. | ||
| const getCardValue = require("../implement/3-get-card-value"); | ||
|
|
||
| test("should return 11 for Ace of Spades", () => { | ||
| test("should return 11 for Ace of Spades",() =>{ | ||
| const aceofSpades = getCardValue("A♠"); | ||
| expect(aceofSpades).toEqual(11); | ||
| }); | ||
|
Comment on lines
+5
to
8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a similar test for Ace on lines 31-37. |
||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return the number value 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): | ||
| test("should return 11 for any Ace",() =>{ | ||
|
|
||
| expect(getCardValue("A♦")).toEqual(11); | ||
|
|
||
| expect(getCardValue("A♥")).toEqual(11); | ||
|
|
||
| }); | ||
|
|
||
| // Case 5: Handle Invalid Cards: | ||
| test("Invalid cards throw error",() =>{ | ||
|
|
||
| expect(() => getCardValue("Z♠")).toThrow("Invalid card rank"); | ||
|
|
||
| expect(() => getCardValue("1♣")).toThrow("Invalid card rank"); | ||
|
|
||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| function countChar(stringOfCharacters, findCharacter){ | ||
|
|
||
| let count =0; | ||
|
|
||
| for (let i = 0;i<stringOfCharacters.length;i++){ | ||
|
|
||
| if (stringOfCharacters[i] ===findCharacter){ | ||
|
|
||
| count =count +1; | ||
| } | ||
| } | ||
|
|
||
| return count; | ||
| } | ||
|
||
|
|
||
| module.exports = countChar; | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the definition of proper fraction in mathematics:
isProperFraction(-4, 3)should returnfalseisProperFraction(-2, 5)should returntrueisProperFraction(-1, 1)should returnfalseisProperFraction(-2, -3)should returntrueCan you look up the definition of proper fraction and update your function accordingly?