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

  Create a program that finds longest word in the dictionary

Write a program that finds the longest word in the dictionary that is spelled using only those six letters.

  Value appear in the output array in the same order

CSCE 4110 University of North Texas - sorting algorithms are stable: insertion sort, merge sort, heapsort, and quicksort? Give a simple scheme that makes

  Create a detailed diagram or set of diagrams to show how

create a detailed diagram or set of diagrams to show how the letter a is transmitted in an electrical light and radio

  The difference between animation and transition effects

When are they appropriate? When is it better not to use them? Can you give me an examples.

  Discuss how net neutrality will affect data networks

Base on your article review and the assigned reading, discuss how net neutrality will affect data networks and the availability of information to businesses.

  What is going on with the discussions

JavaScript can add another dimension to our sites with simple math calculations, such as working with conditionals for an order form to add the proper taxes.

  How business intelligence is being used

Conduct some independent research on the process of business intelligence. Using at least two scholarly or practitioner sources, write a two-page paper giving.

  What that article consider short-coming in citibank planning

Using a web browser and a search engine, search the terms "Citibank backup tapes lost." You will find many results. Select one article and identify what that.

  How would classroom planning and instruction need to change

EDUC 730 Liberty University - How would classroom planning and instruction need to change in order to fully capitalize on the strengths of problem-based

  Research best practices for system integration approaches

1.research best practices for system integration approaches such as the systems development life cycle sdlc approach

  Operation for circular linked list

Write down an algorithm or code segment for searching the circular linked list for a given item. Write down an algorithm or the code segment for locating nth successor of an item within a circular linked list (nth item which follows the given item ..

  Explain porters five forces model

Describe for Bill what a Supply Chain Management (SCM) solution would look like for his ABC Pizza business and how his business could benefit from implementing an SCM solution.

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