Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This application is meant as a start to the implementation of games that might use 52 -card derks. In this initial stage, the goal is

image text in transcribedimage text in transcribed

This application is meant as a start to the implementation of games that might use 52 -card derks. In this initial stage, the goal is the layout of card images on a 4x13 grid (4 rows and 13 columuns). In the initial position, esch row should be a suit of cards: Diamonds in row 1, then Hearts in Row 2, then Spades in row 3, and finally Clubs in row 4. The three control buttons (Shuftle, Reset, and Quit), which are not part of the grid, should sit on the interface below the cards, ies at the bottom of the interface. The GUI actions should function as follows: - Initial layout will organize the cards as abowe (Diamonds in row 1, then Hearts, Spades, and Clubs). The cards should be organized from left to right in order: Ace, 2,3,4,5,6,7,8, 1 9, 10, Jack, Queen, King. This is the starting organization that you should show when the program is first launched (see Figure 1). - The buttons should all function independently. The user can click any of the three any time. - Sluffle button: shuftle the cards and layout the newly-shuffled cards on the interface. Every time the Shuffle button is clieked, the cards should be shuffled anew and repositioned on the layout (see Figure 2) - Reset buttoa: put the card layout back to the initial position (Diamonds in row 1, ete., with cards in ascending order from left to right). - Quit button: end the application. Figure 1: Initial Card Layout 4 The Approach and Implementation One way to approach this layout problem is to use parallel vectors of QPushBut ton and Card objects, as demonstrated in the griddeno example from class. The icons should be read from the resource: file system Another thing to consider is the layout of the cards. A QGridlayout will work fine, but placing all cards on the layout manually may be tedious. Consider adding the cards algorithmically in the MainWindos constructor using the QWidget : :addWidget () member function. Since your cards are stored in a std:svector, you can easily use the std: shuffle and std: : eort algorithms for shuffling and sorting- Using std::sort will require you to owerload 4 The Approach and Implementation One way to approach this layout problem is to use parallel vectors of QPushBut ton and Card objects, as demonstrated in the griddeno example from class. The icons should be read from the resource file system Another thing to consider is the layout of the cardx. A QGridLayout will work fine, but placing all cards on the layout manually may be tedious. Consider adding the cards algorithmically in the MainWindow constructor using the QWidget::addWidget () member function- Since your cards are stared in a std:svector, you can easily use the std::shuffle and std::sort algorithms for shuftling and sorting- Using std::sort will require you to overload Page 2 Figure 2: Shuffled Cards operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions