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

Fall 2024 - CS304P - 2

Uploaded by

humii2224
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)
7 views2 pages

Fall 2024 - CS304P - 2

Uploaded by

humii2224
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

Assignment No.

02(Graded) Total Marks: 20


Semester: Fall 2024
CS304P- Object Oriented Programming (Practical) Due Date: 30 December, 2024

Uploading instructions:

 Your assignment should be in .cpp files (Any other formats like scan images, doc/docx, PDF, zip, rar and
bmp, etc. will not be accepted).
 Save your assignment with your ID (e.g. bc000000000.cpp).
 No assignment will be accepted through email.

Rules for Marking:

It should be clear that your assignment will not get any credit if:

 The assignment is submitted after the due date.


 The submitted assignment does not open or the file is corrupted.
 Your assignment is copied from the internet, handouts, or any other student.
(Strict disciplinary action will be taken in this case).

Lectures Covered:

This assignment covers Labs # 6 to 7

Note: Submit your solutions in .cpp file.

Assignment No. 1

Objectives and Learning Outcomes:

The objectives and learning outcomes of this assignment are to:

 Overload pre and post increment and decrement operators

Problem Statement
Suppose you are tasked with developing a simple and fun virtual game to demonstrate key programming concepts
in C++. The game involves a "virtual player" attempting to guess a randomly generated target number.

Game Rules:

o A target number is generated randomly at the start of the game from 1 to 10.
o The virtual player starts with an initial score of 5 and starts guessing the number.
o You are required to overload pre- and post-increment (++) and decrement (--) operators to manage the
player's score dynamically.
o If virtual player guesses a number that is greater or smaller than the target number, then player score will
be decremented by 1.
 Use the pre-decrement (--score) for guesses that are greater than target number.
 Use the post-decrement (score--) for guesses that are smaller than the target number.
o A correct guess increases the score by 1 using the pre-increment (++score) operator.
o The game ends when:

You might also like