Skip to content

Commit

Permalink
Merge pull request #24 from josemoracard/solution
Browse files Browse the repository at this point in the history
created solution branch
  • Loading branch information
tommygonzaleza authored Oct 18, 2023
2 parents e62a12e + 1731ea0 commit bc86765
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
14 changes: 14 additions & 0 deletions solution/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Card Dealer</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="centered">
<div id="theCard" class="card">
<p id="cardContent"></p>
</div>
</div>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions solution/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
window.onload = function() {

let cardNumber = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"];
let suit = ["Diamonds", "Spades", "Hearts", "Clubs"];
let randomCardNumber = Math.floor(Math.random() * cardNumber.length);
let randomSuitNumber = Math.floor(Math.random() * suit.length);
let finalSuit = suit[randomSuitNumber];

document.getElementById('cardContent').innerHTML = cardNumber[randomCardNumber];
document.getElementById('theCard').className = "";
document.getElementById('theCard').classList.add("card");
document.getElementById('theCard').classList.add(getSuiteClass(finalSuit));
}

function getSuiteClass(suit) {
switch (suit) {
case "Diamonds": return "suit-diamonds";
case "Spades": return "suit-spades";
case "Hearts": return "suit-hearts";
case "Clubs": return "suit-clubs";
}
}
114 changes: 114 additions & 0 deletions solution/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
@charset "UTF-8";
body {
background: green;
}
.centered{margin-left: auto;margin-right: auto; width: 300px;}
a.button {
display: block;
width: 300px;
height: 50px;
background: SandyBrown;
font-family: Arial;
text-decoration: none;
font-size: 25px;
line-height: 50px;
text-align: center;
color: #444;
font-weight: bold;
border-radius: 5px;
box-shadow: 3px 3px 7px rgba(0, 0, 0, 0.3);
margin-top: 20px;

}
a.button:hover {
background: #f7bf90;
}

.card {
width: 300px;
height: 440px;
border-radius: 15px;
background: white;
box-shadow: 3px 3px 7px rgba(0, 0, 0, 0.3);
position: relative;
}
.card p {
font: 150px/440px Arial, serif;
text-align: center;
}

div.suit-hearts:before {
content: "♥";
font-size: 90px;
position: absolute;
top: 8px;
left: 20px;
color: red;
}

div.suit-hearts:after {
content: "♥";
font-size: 90px;
position: absolute;
bottom: 8px;
right: 20px;
color: red;
transform: rotate(180deg);
}

div.suit-diamonds:before {
content: "♦";
font-size: 90px;
position: absolute;
top: 8px;
left: 20px;
color: red;
}

div.suit-diamonds:after {
content: "♦";
font-size: 90px;
position: absolute;
bottom: 8px;
right: 20px;
color: red;
transform: rotate(180deg);
}

div.suit-spades:before {
content: "♠";
font-size: 90px;
position: absolute;
top: 8px;
left: 20px;
color: black;
}

div.suit-spades:after {
content: "♠";
font-size: 90px;
position: absolute;
bottom: 8px;
right: 20px;
color: black;
transform: rotate(180deg);
}

div.suit-clubs:before {
content: "♣";
font-size: 90px;
position: absolute;
top: 8px;
left: 20px;
color: black;
}

div.suit-clubs:after {
content: "♣";
font-size: 90px;
position: absolute;
bottom: 8px;
right: 20px;
color: black;
transform: rotate(180deg);
}

0 comments on commit bc86765

Please sign in to comment.