Write methods that will allow you to emulate a deck of cards

Assignment Help Computer Engineering
Reference no: EM132107301

Program Specification: You are to write methods that will allow you to emulate a deck of cards to be used to play games of chance

• There is a deck of 36 cards:

- Each card has value - a number in the range of [1, 9] printed on it - 9 possible values.

- Each card has a suit - ["Club", "Spade", "Heart", "Diamond"] printed on it - 4 possible suits.

- Thus we will use the numbers from 0 to 35 (inclusive) to represent the cards.

- Given a card ([0, 35]): the card's number is given by card % 9 + 1; the card's suit is given by card / 9, where 0 = "Club", 1 = "Spade", 2 = "Heart", and 3 = "Diamond".

- The deck is "cut" by picking a random point to divide the deck, and then swapping the stack of cards below the cut point with the stack at and above the cut point.

- The deck is "shuffled" by doing the following repeatedly: "cut" the deck, then divide the deck exactly in half

- creating two stacks, and finally recombining the two stacks back into one by selecting the top card from each stack (in alteration).

You must represent the deck of cards using an int Array of of size 36.

• For each of the following headings / descriptions, write and use a method that adheres to it:

- public static int cardValue(int card) Return the integer value ( [1, 9] ) of card

- public static String cardSuit(int card) Return the suit ( ["Club", "Spade", "Heart", "Diamond"] ) of card

- public static void displayCard(int card) Prints card in some reasonable report format.

- public static void initDeck(int[] deck) Assign the elements of deck, such that each element's value is the same as its index.

- public static void cutDeck(int[] deck)

1. Generate a random number ( cut ) in the range 6 to 24 inclusive.

2. Create two new int arrays ( top, bottom ): the size of top being cut; the size of bottom being 36 - cut.

3. Copy the values of deck (from index 0 to index cut - 1) into top and the values of deck (from index cut to index 35) into bottom.

4. Copy the values from top and bottom back into deck, such that the the values of bottom (in the same order they were in) occupy the indicies from 0 to 36 - cut - 1, and the values of top (in the same order they were in) occupy the remaining indicies.

- public static void shuffleDeck(int[] deck, int n) The following is performed exactly n times:

1. Cut the deck

2. Create two new int arrays ( top, bottom ), the size of each being 18

. 3. Copy the first half of deck into top and the second half of deck into bottom.

4. Copy the values from top and bottom back into deck such that: the even indecies of deck hold the values of top (in the same order they were in); the odd indecies of deck hold the values of bottom (in the same order they were in).

- public static void displayDeck(int[] deck) Prints the cards in deck in some reasonable report format.

• Write a main method to test your methods for correctness.

Notes and Hint

You will need to be creative when writing your main method to make sure that you have tested all of your methods adequate.

Reference no: EM132107301

Questions Cloud

Recent meta-analysis evaluating low-fat diets in western : Why would a high carbohydrate, low fat diet lead to increased obesity. Please explain hormones that are involved and mechanism for full credit
What percentage of program execution must be run : What percentage of program execution must be run in parallel mode to achieve the overall speedup of one-half the maximum speedup attainable.
Differences between type 1 and type 2 diabetes : Please explain diabetes to the class, specifically the differences between type 1 and type 2 diabetes (do not include gestational diabetes or diabetes insipidus
Merits and two disadvantages of this idea : Explain at least two merits and two disadvantages of this idea. What would be your recommendation and what information from the readings
Write methods that will allow you to emulate a deck of cards : Program Specification: You are to write methods that will allow you to emulate a deck of cards to be used to play games of chance.
What are the advantages of omega-3 fatty acids : What are the advantages of omega-3 fatty acids? What foods provide good sources of omega 3 fatty acids?
Write a function that takes a positive integer : In either case, you may not use your book or your notes. The directions of the previous part of the final exam holds.
Stage of homogenization in effect on the material : What is role of the first and second stage of homogenization in their effect on the material?
Predominately using in this type of exercise : What sources of fuel is Jeremy predominately using in this type of exercise? How much fluid should Jeremy be consuming during a 3-hour run?

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