0% found this document useful (0 votes)
6 views2 pages

Assignment 1

The assignment for the Data Structures course at COMSATS University requires students to create a card game using stack data structures in C/C++. Players will build a tower of cards by following specific rules, with a scoring system based on successful actions. Submissions must include a complete program, a report on stack operations, and test cases, with a due date of March 18, 2025.

Uploaded by

kakashikage2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Assignment 1

The assignment for the Data Structures course at COMSATS University requires students to create a card game using stack data structures in C/C++. Players will build a tower of cards by following specific rules, with a scoring system based on successful actions. Submissions must include a complete program, a report on stack operations, and test cases, with a due date of March 18, 2025.

Uploaded by

kakashikage2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMSATS University Islamabad (Lahore Campus)

Assignment<1> - SPRING 2025


Course Title: Data Structures Course Code: CSC211 Credit Hours: 4(3,1)

Course Instructor: Humera Niaz Program Name: BS(CS)

Due Date: 18-03-2025 Maximum Marks: 25

Important Instructions / Guidelines:


The submission date is March 18, 2025. Submit your assignment in the form of a report. It should contain a
problem statement, solution (code), and output. Your pdf/docx file name should be your registration no.
Upload your file on Google Classroom.
Ensure your program runs without errors and follows the structure outlined above.
Learning Objectives: Demonstrate the knowledge of stack data structure in C/C++programming.

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 Players can pop the top card from 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.

o -1 point for each card popped from the stack.

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.

o Include functions to push, pop, and peek at the top card.

2. Gameplay Loop:
o Allow the player to enter commands to add (push) or remove (pop) cards.

o Display the current stack after each action.

o Keep track of the score based on the actions performed.

3. End Game Display:


o When the game ends, display the final score and the cards remaining in the stack.

Submission Requirements:

• A complete C/C++ program implementing the game.

• A brief report explaining the stack operations used and how they relate to the game.

• Include test cases demonstrating the functionality of the game.

Grading Criteria:
• Correctness of stack implementation (10 points)

• Functionality of the game (10 points)

• Code quality and documentation (5 points)

You might also like