Fall 2024 - CS304P - 2
Fall 2024 - CS304P - 2
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.
It should be clear that your assignment will not get any credit if:
Lectures Covered:
Assignment No. 1
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: