Preciso criar um objeto com os possíveis naipes e números (faces). Esse objeto tem que ter setters e getters, além de um método shuffle que determina naipe e face (como se tirassem carta aleatória do baralho). O código abaixo está dando o erro “naipe is not defined”. Podem me ajudar?
<!DOCTYPE html>
<html>
<head>
<title>Testes</title>
<script>
/*Write a constructor function for a Card object with properties of suit (diamonds, hearts, spades, or clubs) and face (ace, 2, 3 ...king). Add methods to set the values of suit and face. Can you include a shuffle method to set the suit and face properties to represent a random card from the deck? (Hint: Use the Math.random() method*/
function Card(){
this.naipe = ['paus', 'ouros', 'copas', 'espadas'];
this.face = ['A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2'];
this.setNaipe = function(){
this.naipe = naipe;
}
this.setFace = function(){
this.face = face;
}
this.shuffle = function(){
this.naipe = naipe[Math.floor(Math.random() * naipe.length)];
this.face = face[Math.floor(Math.random() * naipe.length)];
}
}
var carta = new Card();
carta.shuffle();
alert('Naipe ' + carta.naipe);
alert('Face ' + carta.face);
</script>
</head>
<body>
</body>
</html>