Starting from:
$30

$24

Assignment #3 Class Inheritance, Copy Constructor and Assignment Operator Solution

Total Score: 12 points







1 Assignment




1. Write an algorithm to print different ways of arranging 8 rooks on a chess board, so that none of them share the same row or column. Generate and display a few cases. You will be utilizing a two-dimensional array of size 8 × 8. (3 points)




2. Design and implement a class for a deck of cards, named DeckOfCards. It will have suit and rank as its private data members. It will also have the necessary method to return a card with a random suit and rank. Then, use this class to deal the cards to N players. As an example, you can deal 13 cards each to 4 players. The dealt cards will be stored outside the class. You will utilize the function rand() to generate a pseudo random number and the function srand() to seed the random number generator. Remember that you are drawing from the deck, without replacement. (3 points)




3. You have implemented a Complex class in the previous homework. In this problem, you will be implementing an Array class, with some additional features, such as dynamic memory allocation and defining the copy constructor and the assignment operator. Please refer to Stephen Prata, Chapter 12 for details.




(a) The class must have the following data members:




• An int for the array size.

• A pointer to an int for the array elements.

(b) Memory management should be done dynamically using the appropriate new operator in the constructor and the delete operator in the destructor.

(c) The class must also define the following:




• A constructor

• A copy constructor

• Assignment operator

• Addition operator

• A method to sort the array

• A method to display the array elements




Test the code for all of the above functionality. (3 points)




4. Stephen Prata, Chapter 13, Programming Exercise 1 on base class Cd and derived class

Classic. (3 points)










2 Grading




In addition to code functionality, there will be points for optimized algorithm, coding style and comments. A few useful comments would be sufficient.







3 Assignment Submission




The Assignments must be submitted on the Blackboard, and should include the following:




1. The C++ source code, with one file per problem.




2. Screen shots which show each program executing. All the screen shots maybe in a single .pdf or .jpg file.

More products