Question: Python Preliminaries: import random class Card: suit_sym = {0: 'u2663' , 1: 'u2666' , 2: 'u2665' , 3: 'u2660' } rank_sym = {0: '2' ,

Python

Preliminaries:

import random class Card: suit_sym = {0: '\u2663', 1: '\u2666', 2: '\u2665', 3: '\u2660'} rank_sym = {0: '2', 1: '3', 2: '4', 3: '5', 4: '6', 5: '7', 6: '8', 7: '9', 8: '10', 9: 'J', 10: 'Q', 11: 'K', 12: 'A'} def __init__(self, rank, suit): self.rank = rank self.suit = suit def __repr__(self): return self.rank_sym[self.rank] + self.suit_sym[self.suit] def __eq__(self, other): return self.suit == other.suit and self.rank == other.rank class Player: def __init__(self, card_list): self.card_list = card_list self.score = 0 def __repr__(self): return 'cards: ' + str(self.card_list) + ', score: ' + str(self.score) # Utility function to help with testing. Don't change this function. def build_deck(): card_list = [] for i in range(4): for j in range(13): card_list.append(Card(j, i)) return card_list # Utility function to help with testing. Don't change this function. def build_players(): player_list = [] for i in range(4): player = Player([]) player_list.append(player) return player_list 

Python Preliminaries: import random class Card: suit_sym = {0: '\u2663', 1: '\u2666',

Part III: Determine the Round Winner (20 points) Write a function round.winner ) that takes the following arguments, in this order: 1. current.suit: The suit for the current round of play. 2. cards.on.table: A list of the four Card objects played by each player in the current round cards.on.table[01 is the card that Player 1 played, cards.on.table [1] is the card that Player 2 played, etc Your function should find the Card object in the list cards.on.table that has the highest rank and matches will be of the suit current.suit. Example #1 : cards-on-table = [2w. 3., 4w. 5.] cards-on-table= [Card (0, 2), Card (1, 2), Card (2, 2), Card (3, 2) result = round-winner., cards-on-table) the current.suit and returns the corresponding index. You are guaranteed that at least one card in cars.on.table CSE 101 -Fall 2017 Homework #5 Page 5 Return value: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!