Microsoft Word - Project 3.docx Project3 Yourtaskistowriteaprogramthatplaysasimplecardgamewithonetofour players,oneofwhichisahumanwhiletheremainingarecomputerplayers.The...

Need done as soon as possible before midnight


Microsoft Word - Project 3.docx Project3 Yourtaskistowriteaprogramthatplaysasimplecardgamewithonetofour players,oneofwhichisahumanwhiletheremainingarecomputerplayers.The gameusesadeckof52cards.Eachcardhasavalue(eitheranumber2through10 oralabeljack,queen,king,orace)andasuit(hearts,diamonds,clubsorspades). Theobjectiveofthegameistogetfourcardswiththesamevalue.Forexample,the 8ofhearts,diamonds,clubsandspades. Atthebeginningofthegame,thecardsareshuffledandeachplayerisgivenfour cards.Theremainingcardsareplacedintoa“drawpile.”Thereisanotherpilecalled the“discardpile”thatstartsoutempty. Ifnoplayerhasbeendealtawinninghand,theplayerstaketurnsuntiloneofthem wins.Ateachturntheplayercaneitherdrawanewcardfromthedrawpileorpick upbetweenoneandn-1cardsfromthediscardpile,wherenisthenumberof players.Theplayerthendiscardsthenumberofcardstheypickedup.So,for example,ifthegameisbeingplayedwithonehumanandthreecomputers(son= 4),aplayermaydecidetopickupthreecardsfromthediscardpile.Theplayermust thendiscardthreecardsthemselves,sothatthenumberofcardsintheirhand remainsatfour. Randomlychooseaplayertogofirst.Becausethediscardpilestartsoutempty,the firstplayermustinitiallypickupacardfromthedrawpile.Afterthat,thefirst playermustselectacardtoputintothediscardpile.Thiscaneitherbethecardthey dreworonethatwasalreadyintheirhand.Ifthefirstplayernowhasfourcards withthesamevalue,theywin.Otherwise,itisthenextplayer’sturn. Thesecondplayercaneitherdrawacardfromthedrawpileorpickupthecardthat thefirstplayerputontothediscardpile.Thenthesecondplayermustplaceoneof theircardsontothediscardpile.Ifthesecondplayernowhasfourcardswiththe samevalue,theywin.Otherwise,itisthenextplayer’sturn;however,thistimethe nextplayercanchoosetotakeoneorbothcardsfromthediscardpileortochoosea cardfromthedrawpile.Ingeneral,onaplayer’sturntheyareallowedtopickup betweenoneandn-1(wherenisthenumberofplayers)cardsfromthediscardpile ORonecardfromthedrawpile.Theplayeralwaysdiscardsenoughcardsoneach turnsothattheirhandhasfourcardswhentheirturnisover. Thisprocessrepeatsuntiloneplayerwins.Atthatpoint,thegameshoulddisplay themessage“PlayerXwins!”ifahumanplayerwonor“Iwin!”ifthecomputer playerwon.Theprogramshouldthenterminate. Anexampleexecutionofthisgameforonehumanplayerandonecomputerplayer isshownintheprogramoutputbelow.Arubricexplaininghowyouwillbegraded followstheexample. Your cards are: Queen of Hearts Seven of Hearts Eight of Hearts Seven of Diamonds The discard pile is currently empty -- you must draw a card You drew the Five of Spades Now your cards are: 1. Queen of Hearts 2. Seven of Hearts 3. Eight of Hearts 4. Seven of Diamonds 5. Five of Spades Which one do you want to discard? 1 I will draw a new card. I will discard the Two of Spades Your cards are: Five of Spades Seven of Hearts Eight of Hearts Seven of Diamonds The top card in the discard pile is the Two of Spades Do you want to pick up the Two of Spades (1) or draw a card (2)? 2 You drew the Queen of Diamonds Now your cards are: 1. Five of Spades 2. Seven of Hearts 3. Eight of Hearts 4. Seven of Diamonds 5. Queen of Diamonds Which one do you want to discard? 1 I will pick up the Five of Spades I will discard the Six of Diamonds Your cards are: Queen of Diamonds Seven of Hearts Eight of Hearts Seven of Diamonds The top card in the discard pile is the Six of Diamonds Do you want to pick up the Six of Diamonds (1) or draw a card (2)? 2 You drew the Five of Diamonds Now your cards are: 1. Queen of Diamonds 2. Seven of Hearts 3. Eight of Hearts 4. Seven of Diamonds 5. Five of Diamonds Which one do you want to discard? 1 I will draw a new card. I will discard the King of Spades Your cards are: Five of Diamonds Seven of Hearts Eight of Hearts Seven of Diamonds The top card in the discard pile is the King of Spades Do you want to pick up the King of Spades (1) or draw a card (2)? 2 You drew the Nine of Diamonds Now your cards are: 1. Five of Diamonds 2. Seven of Hearts 3. Eight of Hearts 4. Seven of Diamonds 5. Nine of Diamonds Which one do you want to discard? 5 I will draw a new card. I will discard the Queen of Spades Your cards are: Five of Diamonds Seven of Hearts Eight of Hearts Seven of Diamonds The top card in the discard pile is the Queen of Spades Do you want to pick up the Queen of Spades (1) or draw a card (2)? 2 You drew the Six of Spades Now your cards are: 1. Five of Diamonds 2. Seven of Hearts 3. Eight of Hearts 4. Seven of Diamonds 5. Six of Spades Which one do you want to discard? 5 I will draw a new card. I will discard the Four of Clubs Your cards are: Five of Diamonds Seven of Hearts Eight of Hearts Seven of Diamonds The top card in the discard pile is the Four of Clubs Do you want to pick up the Four of Clubs (1) or draw a card (2)? 2 You drew the Seven of Spades Now your cards are: 1. Five of Diamonds 2. Seven of Hearts 3. Eight of Hearts 4. Seven of Diamonds 5. Seven of Spades Which one do you want to discard? 3 I will draw a new card. I will discard the Ten of Diamonds Your cards are: Five of Diamonds Seven of Hearts Seven of Spades Seven of Diamonds The top card in the discard pile is the Ten of Diamonds Do you want to pick up the Ten of Diamonds (1) or draw a card (2)? 2 You drew the King of Diamonds Now your cards are: 1. Five of Diamonds 2. Seven of Hearts 3. Seven of Spades 4. Seven of Diamonds 5. King of Diamonds Which one do you want to discard? 5 I will draw a new card. I will discard the Three of Diamonds Your cards are: Five of Diamonds Seven of Hearts Seven of Spades Seven of Diamonds The top card in the discard pile is the Three of Diamonds Do you want to pick up the Three of Diamonds (1) or draw a card (2)? 2 You drew the Three of Clubs Now your cards are: 1. Five of Diamonds 2. Seven of Hearts 3. Seven of Spades 4. Seven of Diamonds 5. Three of Clubs Which one do you want to discard? 5 I will draw a new card. I will discard the Seven of Clubs Your cards are: Five of Diamonds Seven of Hearts Seven of Spades Seven of Diamonds The top card in the discard pile is the Seven of Clubs Do you want to pick up the Seven of Clubs (1) or draw a card (2)? 1 Now your cards are: 1. Five of Diamonds 2. Seven of Hearts 3. Seven of Spades 4. Seven of Diamonds 5. Seven of Clubs Which one do you want to discard? 1 You win! Yourprogramwillbegradedaccordingtothisrubric: [45points]Thebasicgameplayisimplementedasdescribed. [15points]Thecomputerplayerdisplayssome“intelligence”inchoosingitsactions (i.e.itdoesn’trelysolelyonrandomnumbergeneration). [15points]Datastructuresarechosenandutilizedappropriately. [15points]Goodobject-orienteddevelopmentprinciplesarefollowed.Theprogram islogicallyorganizedintoclasseswithappropriatefieldsandmethods.TheModel- View-Controllerdesignpatternisfollowed. [10points]Thecodeisclearlywritten,includingfollowingstandardcoding conventionsandcontainingmeaningfulcomments. Extracreditopportunity:YoucanimplementaGUIversionofthisapplicationfor onepointofextracreditonyouroverallgradeinthecourse.
Jul 12, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here