Roshambo is the classic rock paper scissors game This is a c

Roshambo is the classic rock, paper, scissors game. This is a card game involving a deck of 66 cards, 22 of which have a picture of a rock, 22 have a picture of a piece of paper, and 22 have a picture of a pair of scissors. The game starts as follows: The player and the house are each dealt four cards. The player is asked to make a bet that he will win the hand, with the winner of the hand (and bet) being determined by who scores the most points (in the event of a tie, the house wins). The dealer reveals his first card. The player then chooses a card to play. A point is scored by whoever wins, or no points if it is a tie. The player then reveals a card, and the computer plays a card (assume perfect play). The hand continues, alternating who reveals first, until all four cards are played. The player receives the bet amount from the dealer if he wins, otherwise that amount is deducted from the player\'s account. If the player decides, a new hand is dealt and play repeated. Play ends when the player runs out of money, or he chooses to quit. Your Python implementation: Create a Deck class that has a list of Cards, and a method that deals a card from the list (randomly, without replacement, just like in the earlier homework card games), and a constructor that sets up the list of randomly shuffled cards. Create a Card abstract class that has an integer value (an instance variable). Put in a constructor that sets the integer value (it takes an int as a parameter). Create RockCard, PaperCard, and ScissorsCard classes that inherit from Card. The RockCard\'s integer value will be 0. PaperCard will have 1, and ScissorsCard will have 2. They will also each have a class variable with the appropriate string representation for that kind of card. Finally, they will have an instance method that takes in a Card as an argument and returns a boolean that reflects whether this card beats the other card. Implement the game play as described above. When the deck runs out of cards, just make a new deck (using the constructor).

Solution

from abc import ABCMeta, abstractmethod import sys import random # // abstaract class that has an integer value # // has a constructor that takes in an int value class Card(object): ___metaclass__ = ABCMeta @abstractmethod def __init__(self, intValue): print(intValue) class RockCard: string = \"Rock\" intValue = 0 def __init__(self, Card): print(\'never called and goes to __new__\') def __new__(cls, Card): if (Card.intValue == 1): return True if (Card.intValue == 0): return False if(Card.intValue == 2): return False #integer value 0 # appropriate String representatrion for the suit # inherit from Card #instance method takes a card as an argument returns boolean # (cont) reflects wheter this card beats the other card class PaperCard: string = \"Paper\" intValue = 1 def __init__(self, Card): print(\'never called and goes to __new__\') def __new__(cls, Card): if (Card.intValue == 1): return False if (Card.intValue == 0): return False if(Card.intValue == 2): return True #integer value 1 # appropriate String representatrion for the suit # inherit from Card #instance method takes a card as an argument returns boolean # (cont) reflects wheter this card beats the other card class ScissorsCard: string = \"Scissors\" intValue = 2 def __init__(self, Card): print(\'never called and goes to __new__\') def __new__(cls, Card): if (Card.intValue == 1): return False if (Card.intValue == 0): return True if(Card.intValue == 2): return False # integer value 2 # appropriate String representatrion for the suit # inherit from Card #instance method takes a card as an argument returns boolean # (cont) reflects wheter this card beats the other card #listofCards #method that deals a card from the list randomly without replacement like hw2 #a constructor that sets up the list of rand # omly shuffled cards #make a new deck using constructor when cards run out class Deck(object): listOfCards = {} deckArray=[] rockCard = RockCard paperCard = PaperCard scissorsCard = ScissorsCard def __init__(self): print(\"inside constructor\") # self.initializeKeyArray() self.createDeck() self.shuffle() self.amountOfCardsCheck() def amountOfCardsCheck(self): print(\"amountOfCardsCheck line 95 \") if len(self.deckArray) <= 8: print(\"if len(self.deckArray)<= 3:\") self.shuffle() def createDeck(self): for i in range(66): if(i <= 22): self.listOfCards[i] = self.rockCard.string # self.listOfCards[i] = str(i % 22) + \" Rock\" if (i > 22 and i <= 44): self.listOfCards[i] = self.paperCard.string # self.listOfCards[i] = str(i % 22) + \" Paper\" if (i >= 44 and i <= 66): self.listOfCards[i] = self.scissorsCard.string # self.listOfCards[i] =str(i % 22) + \" Scissors\" # def initializeKeyArray(self): # print(\"initialize Array\") # self.deckArray = list(range(66)) # print(self.deckArray) # print(len(self.deckArray)) def printDeck(self): for i in self.listOfCards: print(str(i) + \" \" + str(self.listOfCards[self.deckArray[i]])) def shuffle(self): self.deckArray = list(self.listOfCards) random.shuffle(self.deckArray) self.deckArray[:66] self.printDeck() class Deal(object): card1 = None card2 = None card3 = None card4 = None card5 = None card6 = None card7 = None card8 = None deck = Deck() userCardsOfArray = [] def __init__(self): self.card1 = Deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card2 = self.deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card3 = self.deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card4 = self.deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card5 = Deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card6 = self.deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card7 = self.deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) self.card8 = self.deck.listOfCards[self.deck.deckArray[0]] self.deck.deckArray.pop(0) # print(self.card1) # print(self.card2) # print(self.card3) # print(self.card4) # def secondDeal(self): def userMenu(self): self.createTempArray() print(\"User gets four cards\") print(\"1. \" + self.card5) print(\"2. \" + self.card6) print(\"3. \" + self.card7) print(\"4. \" + self.card8) print(\"Pick a Card to play\") def createTempArray(self): self.userCardsArray[0]= self.card5 self.userCardsArray[1] = self.card6 self.userCardsArray[2] = self.card7 self.userCardsArray[3] = self.card8 # def showDealersCards(self): # print(\'show Dealers cards\') class SetGameStatus: exit = False bet = 0 # rockCard = RockCard # paperCard = PaperCard # scissorsCard = ScissorsCard # Card(rockCard.intValue) # Card(rockCard.string) # Card(paperCard.intValue) # Card(paperCard.string) # Card(scissorsCard.intValue) # Card(scissorsCard.string) # status = rockCard(paperCard) # print(\"printing status: \" + str(status)) #deal all four cards to house and then deal four cards to user #user chooses a card and then the card flips over #once it flips, it gets compared with the house card and compare between #findWinner is using the #add all the points and then have it tally the score of who wins the round and the bet goes to the winner #reset the cards if its less than 8 deal = Deal() while(not SetGameStatus.exit ): print(\"test \" + str(SetGameStatus.exit)) SetGameStatus.bet = input(\"Enter your Bet $\") print(\"\ D E A L I N G 4 C A R D S to H O U S E\" ) print(\"House gets four cards \ |*| |*| |*| |*|\") print(\"\ D E A L I N G 4 C A R D S to U S E R\" ) deal.userMenu() # print(RockCard(ScissorsCard)) # if(RockCard(ScissorsCard) == True): # print(\"if(RockCard(ScissorsCard))\" + str((RockCard(ScissorsCard)))) SetGameStatus.exit = True
 Roshambo is the classic rock, paper, scissors game. This is a card game involving a deck of 66 cards, 22 of which have a picture of a rock, 22 have a picture o
 Roshambo is the classic rock, paper, scissors game. This is a card game involving a deck of 66 cards, 22 of which have a picture of a rock, 22 have a picture o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site