Skip to content

LON | Amirhossein Aminian | Module-structuring-and-testing-data | sprint3 #142

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 38 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a9422f3
get-angle
AmirhosseinAminian Nov 10, 2024
fcbc6ce
get-card-value
AmirhosseinAminian Nov 11, 2024
c4029b3
fraction
AmirhosseinAminian Nov 12, 2024
73fb2ad
valid-triangle
AmirhosseinAminian Nov 12, 2024
5f53537
rotate-chart
AmirhosseinAminian Nov 13, 2024
22b26ab
credit_card_number
AmirhosseinAminian Nov 13, 2024
d0f894d
count_char
AmirhosseinAminian Nov 14, 2024
a04f883
ordinal_number-test
AmirhosseinAminian Nov 14, 2024
37c799f
Fixing feedback
AmirhosseinAminian Nov 14, 2024
3a19cbb
is_prime
AmirhosseinAminian Nov 14, 2024
9617648
feedback
AmirhosseinAminian Nov 14, 2024
048a134
password_validation
AmirhosseinAminian Nov 14, 2024
7f4fdbe
repeat_test
AmirhosseinAminian Nov 14, 2024
0696a5a
find.js
AmirhosseinAminian Nov 14, 2024
bf0c3b5
find.js
AmirhosseinAminian Nov 14, 2024
bb8e1c8
Merge branch 'main' into amiraminia/sprint3
SallyMcGrath Nov 21, 2024
2ce2bba
java to javascript
AmirhosseinAminian Nov 21, 2024
004e0ec
Merge branch 'amiraminia/sprint3' of https://github.com/Amir200524/Mo…
AmirhosseinAminian Nov 21, 2024
6d213de
java to javascript
AmirhosseinAminian Nov 21, 2024
b402751
java to javascript
AmirhosseinAminian Nov 21, 2024
e964339
converting to JavaScript
AmirhosseinAminian Nov 21, 2024
c970c82
more test case
AmirhosseinAminian Nov 21, 2024
fd5fd05
jest test
AmirhosseinAminian Nov 23, 2024
e480c7d
deleted example file
AmirhosseinAminian Nov 23, 2024
9423d02
generating test.js
AmirhosseinAminian Nov 23, 2024
b5dd0e1
fixing feedback
AmirhosseinAminian Nov 23, 2024
2160580
fixing password.test
AmirhosseinAminian Nov 23, 2024
6fbaaa4
generating count.test
AmirhosseinAminian Nov 23, 2024
e8ae613
generating get-ordinalnumber.test
AmirhosseinAminian Nov 23, 2024
e54439f
generating password-validator.test
AmirhosseinAminian Nov 23, 2024
e112659
generating repeat.test
AmirhosseinAminian Nov 23, 2024
9507417
fixing code
AmirhosseinAminian Nov 23, 2024
acf58fb
fixing repeat.test & repeat.js
AmirhosseinAminian Nov 23, 2024
67e8477
test of number of digits is exactly 16
AmirhosseinAminian Nov 30, 2024
b71f5a4
generate ifs for special case and skip even numbers
AmirhosseinAminian Nov 30, 2024
c88ad5f
export previousPasswords
AmirhosseinAminian Nov 30, 2024
b547b6c
Handles the special case & Eliminates even numbers
AmirhosseinAminian Nov 30, 2024
4018a61
Shift Normalization
AmirhosseinAminian Nov 30, 2024
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
Prev Previous commit
Next Next commit
get-card-value
  • Loading branch information
AmirhosseinAminian committed Nov 11, 2024
commit fcbc6ceb84b46507f505d98bab389bccc1e73686
86 changes: 56 additions & 30 deletions Sprint-3/implement/get-card-value.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
// This problem involves playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck
public class CardValue {

// Function to get the card value based on blackjack rules
public static int getCardValue(String card) {
String rank = card.substring(0, card.length() - 1);

switch (rank) {
case "A":
return 11;
case "K":
case "Q":
case "J":
case "10":
return 10;
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
return Integer.parseInt(rank);
default:
throw new IllegalArgumentException("Invalid card rank");
}
}

public static void main(String[] args) {
// Test cases for different scenarios
assert getCardValue("A♠") == 11 : "Ace should be worth 11 points";
assert getCardValue("K♣") == 10 : "King should be worth 10 points";
assert getCardValue("Q♦") == 10 : "Queen should be worth 10 points";
assert getCardValue("J♥") == 10 : "Jack should be worth 10 points";
assert getCardValue("10♠") == 10 : "10 should be worth 10 points";
assert getCardValue("9♣") == 9 : "9 should be worth 9 points";
assert getCardValue("5♦") == 5 : "5 should be worth 5 points";

// Testing invalid card rank
try {
getCardValue("1♠");
assert false : "Expected IllegalArgumentException for invalid rank '1'";
} catch (IllegalArgumentException e) {
assert e.getMessage().equals("Invalid card rank") : "Exception message should be 'Invalid card rank'";
}

try {
getCardValue("Z♦");
assert false : "Expected IllegalArgumentException for invalid rank 'Z'";
} catch (IllegalArgumentException e) {
assert e.getMessage().equals("Invalid card rank") : "Exception message should be 'Invalid card rank'";
}

System.out.println("All tests passed!");
}
}

// You will need to implement a function getCardValue

// You need to write assertions for your function to check it works in different cases

// 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

// Handle Number Cards (2-10):
// Given a card with a rank between "2" and "9",
// 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).

// 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.

// 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.

// 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."