Add a playgame method to the cardwars class

Assignment Help Computer Engineering
Reference no: EM133370241

Question: Add a PlayGame method to the CardWars class. It should have 3 parameters: List for the cards, List for the high scores, and a string for the name of the high score file.

Here is the game logic to put in PlayGame: 

1. Call shuffle passing in the list of cards. 

2. Take the shuffled list and split it into 2 equal lists: playerCards and npcCards. 

3. Create 3 lists: playerPile, npcPile, unclaimedPile. 

4. Loop while the playerCards list is not empty COP2334 

      a. Print out the first card from playerCards and npcCards (see example below on how to print) 

      b. Add the first card from playerCards and npcCards to the unclaimed pile. 

      c. Call Compare and pass the first card from the playerCards and npcCards. 

               i. NOTE: compare will return -1 if the card1 < card2, 0 if card1 = card2, 1 if card1 > card2 

      d. If Compare returns -1, add the unclaimed pile to the npcPile. Clear the unclaimed pile. Print NPC wins. 

      e. If Compare returns 1, add the unclaimed pile to the playerPile. Clear the unclaimed pile. Print player wins. 

      f. Remove the first card from the playerCards and npcCards. 

5. After the loop, check who won. Print the counts from the playerPile and npcPile lists. 

      a. If the npcPile has more cards, print that the npc won the round. 

      b. If the npcPile has the same number of cards as the playerPile, print that it was a tie.  

      c. Else, the playerPile has more cards. Print out that the player won and check if it's a new high score. 

               i. NOTE: the last score in the high score list is the smallest high score. Therefore, if the playerPile count is greater than                   the last score in the high score list, the player has a new high score. 

               ii. If a new high score, 

                       1. Get the user's name using Input.GetString 

                      2. loop from the beginning of the high score list 

                      3. If the score is >= the high score, then

                            a. insert the high score into the list at that index 

                            b. remove the last score in the list 

                            c. call SaveHighScores (method already created)

Reference no: EM133370241

Questions Cloud

Discuss how lowering cutoff value relates to changes : add more cutoff values in between the specified intervals to see changes. Discuss how lowering (or raising) cutoff value relates to changes of accuracy
Overview of your concerns from the risk assessment : IFSM 201 University of Maryland Provide an overview of your concerns from the risk assessment report. Include broad 'goal' of the memo, as a result of the risk
Discuss how the 4 ts of risk control : Discuss how the 4 Ts of risk control (i.e., transferring risk, tolerating risk, treating risk, and terminating risk) might be applied to mitigate risk.
Is plastic surgery healthy for the body : Is plastic surgery healthy for the body?
Add a playgame method to the cardwars class : Add a PlayGame method to the CardWars class. It should have 3 parameters: List for the cards, List for the high scores, and a string for the name of the high
Name and describe the health service organization : Name and describe the health service organization. Define its product/service background. Describe its primary target market in terms of the segmentatio
What has been zaras approach to achieving and sustaining : What has been Zara's approach to achieving and sustaining competitive advantage and How has Information Technology (IT) enabled Zara's strategy
What is the significance of pandas : What is the significance of PANDAS (pediatric autoimmune neuropsychiatric disorders associated with streptococcus)? Discuss any ages that are of concern.
Construct a database for a parking service system : Draw an ER diagram for this application. Specify key attributes of each entity type and structural constraints on each relationship type

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd