Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE 101: Introduction to Computational and Algorithmic Thinking Stony Brook University Homework #5 Fall 2017 Assignmient Due: November 26, 2017 by 11:59 pm Assignment Objectives

image text in transcribed

CSE 101: Introduction to Computational and Algorithmic Thinking Stony Brook University Homework #5 Fall 2017 Assignmient Due: November 26, 2017 by 11:59 pm Assignment Objectives For this homework you will be implementing the a simplified version the card game Bridge. You do not need to understand the rules to complete the homework assignmen, hut the Wikipedia page at en.wikipedia.org/wiki/Contract.bridge provides the details. be working with objects that represent the playing cards and the Throughout the entire assignment you players Game Overview n 13 cards. When the game game starts off with 52 cards distributed among 4 players. begins, the first player plays any card he/she wants. Typically this is the card with the highest rank of any suit All other players have to follow the suit. If one of the other players doesn't have a card in that suit, he/she can play a card of any other suit. Typically, this is the lowest rank card the player chooses the play. The winner of a round is determined by the player who placed the highest ranked card of the suit on which the round began. (2 is the lowest rank and Ace is the highest.) The winner of the round scores a point and gets to place hisher card first at the beginning of the next round. This continues until there are no more cards eft to play. The winner is determined by the player who has won most number of rounds r i s give Getting Started Visit Blackboard and download the "bare hones" file homeworkS.py. Open the file in PyCharm and fill in the following information at the top: I. your list and last name as they appear in Blackboard . your Net I e.g josith) 3. your Stony Brook ID # (eg., 1999999) 4. the couse mber (CSE 101) 5-the assignment name and number (Homework #5) Do nol, under any circumstances, change the names of the functions or their argument list The automated CodcLoachesting systen will bc lo(ing for cxactly thosc functions providcd in homework 5.py. You will bc able to test your work by uplouding your file to CodeLoad. Upload your final Py fik to Blackhoard by the due date and time. Late work will not be graded. CSE 101 Fall 2017 Homework #5 calc that crashes and cannot bc graded will carn no crudi. It your responsibility to test your cole by running it through CodeLoad and by creating your own test cascs. Preliminaries For this homework assignment you will be working with the following classes that represent a playing card and a player: cla Card : suit_aym {0: ,\u2663,, 1: ,\u2 666,, 2: ,\u2665', 3: ,\u2660, } = 7:9, 8: '10', 9: J,10:'Q, 11: 'K', 12: A def-init-(self, self. rank self.guit rank, suit); rank su i t = def -repr-(self): return self.rank sym[self.rank self.suit symIself.suit] def-eq-(self, other): return self.su i t == other.suit and self, rank == other.rank class Player: def init (self, card list): self.card.I ist = card-list self.score = 0 defrepr(self): return'cards:+str (self.card list)'score:str (self.score) Data Encoding for the suit Field in the Card Class 0 represents Cluhs nts Diamonds . 2 represe nts Hearts 3 represents Spades Data Encoding for the rank Field in the Card Class represents 2 ] rcpresents 3 1 represents K 12 represents A CSE 101-Fall 2017 Homework 5 age Additional Functionality In the homework5.py tile you will find the typical main if-stalement, but also two functions: run tests( and simulate-gameInside the main scctionatthe very end of the file) you will see that the run.tests) function is called, but imulate.gan e O is commented out. The run.tcats() will cxecute the samc test cases given in the PDE The simulate.game functionl cal the functions you must write to simulate 13-round game of ridge. Although you don't have to use the simulato-game() to test your work you may nd it usuinteresting to watch a game played out from start to finish. Realistically, however, the aimulato-gama0 will crash the program until you have implemented most of the reqired functions. You will be required to write the following five functions (not mcthods) to support playing of the game. Part I: Deal the Cards (20 points) Write a function deal.cards) that takes the following arguments, in this ordkr: l. player.list: A list of 4 Player objects. 2. card list: A list of 52 Card objeets. Your function should deal cach Card objcct in cardliat locach Player inplayerlist in the following order: 1. The first Card object in the card.1ist list is added to first Player objec in player.1ist list. 2. The second Card object in the card list list is added to second P1ayer object in player list list. 3. The third Card objeet in the card.List list is added to third Player objcet in player.list list. The fourth Card objcct in the card.list is is added to fourth Player object in playerlist list. 5. The fifth Cardobject in the card.list list is added to first Player objectinplayer.list list and so This function doesn't return any values. Example: Suppose card.1ist contained the following cards, in this order on, up until the last Card ohject from card.liat has been dealt. The cards would be distributed to the players as follows: CSE 10I Fall 2017 Homework #5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

LO2 Explain the major laws governing employee compensation.

Answered: 1 week ago