1. Deck.java The Deck class represents a deck of cards. It starts off with 52 cards, but as cards are dealt from the deck. the number of cards becomes smaller. The class has one private instance variablo that stores the Carde that are currently in the Deck: private Card] cards; Important Note: The first Card in the array will be considered the card that is at the top of the deck. When cards aro removed from the deck they will be removed from the front of the array. You must implement the following methods for the Deck class: • public Deck0- This constructor initializes the Deck with 52 card objects, representing the 52 cards that are in a standard deck. The cards must be ordered as in the diagram below: Important: The FIRST card in your array should be the Ace of Spades, and the LAST card should be the King of Diamonds. Note that in the picture below, the Ace of Spades is at the TOP of the deck, which is to the left. A234567890J 567890 • public Deck(Deck other)- Standard copy constructor. Note that it is okay to make a shallow copy of the array of cards. (The Card class is immutable, so alinsing Cards is not a problem.) • public Card getCardAt(int position) - Returns the card that is at the specified position in the array (Uses the usual 0-based indexing.) • public int getNumCards)- Returns the sizo of the array of Cards. (It starts off equal to 52, but becomes smaller as cards are dealt from the deck.) • public void shuffle()- This method will re-arrange the cards that are in the deck. The idea is that the deck will be divided into two "packets the top half and the bottom half. The new array of cards will consist of: the first card from the top packet, followed by the first card from the bottom packet, followed by the second card from the top packet, followed by the second card from the bottom packet, etc. Important: If there are an odd number of cards, the top packet should have one more card than the bottom packet. Remember that the top of the deck is considered to be the front of the array. In the pictures below, remember that the top of the deck appears at the left side. Below are two examples of how the shuffle should work Example 1 (even number of cards): Before Shuffling A234567890 5456
1. Deck.java The Deck class represents a deck of cards. It starts off with 52 cards, but as cards are dealt from the deck. the number of cards becomes smaller. The class has one private instance variablo that stores the Carde that are currently in the Deck: private Card] cards; Important Note: The first Card in the array will be considered the card that is at the top of the deck. When cards aro removed from the deck they will be removed from the front of the array. You must implement the following methods for the Deck class: • public Deck0- This constructor initializes the Deck with 52 card objects, representing the 52 cards that are in a standard deck. The cards must be ordered as in the diagram below: Important: The FIRST card in your array should be the Ace of Spades, and the LAST card should be the King of Diamonds. Note that in the picture below, the Ace of Spades is at the TOP of the deck, which is to the left. A234567890J 567890 • public Deck(Deck other)- Standard copy constructor. Note that it is okay to make a shallow copy of the array of cards. (The Card class is immutable, so alinsing Cards is not a problem.) • public Card getCardAt(int position) - Returns the card that is at the specified position in the array (Uses the usual 0-based indexing.) • public int getNumCards)- Returns the sizo of the array of Cards. (It starts off equal to 52, but becomes smaller as cards are dealt from the deck.) • public void shuffle()- This method will re-arrange the cards that are in the deck. The idea is that the deck will be divided into two "packets the top half and the bottom half. The new array of cards will consist of: the first card from the top packet, followed by the first card from the bottom packet, followed by the second card from the top packet, followed by the second card from the bottom packet, etc. Important: If there are an odd number of cards, the top packet should have one more card than the bottom packet. Remember that the top of the deck is considered to be the front of the array. In the pictures below, remember that the top of the deck appears at the left side. Below are two examples of how the shuffle should work Example 1 (even number of cards): Before Shuffling A234567890 5456
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 11 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education