Assignment 1
Assignment 1
Objective:
Create a simple card game where players build a "tower" of cards using stack data structures. The goal is
to simulate placing and removing cards based on specific rules, utilizing stack operations.
Game Rules:
1. Card Representation: Each card is represented by a number (1-13) indicating its value (Ace to
King).
2. Building the Tower:
o Players can push cards onto the stack.
o Cards can only be added if they are of a higher value than the card currently at the top of
the stack. (Card numbers to be placed on the stack are generated Randomly)
o The lower value card can either be discarded or pushed by popping the higher value card
(based on user choice)
3. Winning Condition: The game ends when a player successfully stacks 5 cards in a maximum
of 10 attempts otherwise, he loses.
4. Points System: Points are displayed at the end of the game.
o +2 points for each card successfully added to the tower.
5. Implement a way to view the current stack (tower) and the number of cards in it at any time.
Tasks:
1. Implement the Stack:
o Create a stack data structure to manage the cards.
2. Gameplay Loop:
o Allow the player to enter commands to add (push) or remove (pop) cards.
Submission Requirements:
• A brief report explaining the stack operations used and how they relate to the game.
Grading Criteria:
• Correctness of stack implementation (10 points)