Lab 4: Guess the Date
Overview
In this lab, you will use a provided Date
class to create a guessing game, where the user attempts to guess a pre-defined target date. You will construct a date object from the user’s input, provide the user with hints (e.g., too high, too low).
-
Please email me a code related question before class on Tues 13 Nov.
-
Due Thurs 15 Nov 2018 at midnight
Required Code
-
Use
Date.h
in the following Repl.it-
The
Date
class above includes friend function declarations for boolean operators (<
,>
, and==
). You must provide appropriate definitions for these functions outside of the class definition (e.g., infriends.h
).
-
You must create a function that prompts a user for year, month, and day, and then creates and returns a
Date
object.-
No error checking is required here.
-
Your program should:
-
Construct a
Date
object at the beginning ofmain()
with the target date (your choice). -
Contain a loop that asks the user to guess a date (use the above function).
-
The loop should allow 12 guesses at most.
-
-
Use boolean operators to compare the user’s guess with the target date.
-
If they match, congratulate the user and exit.
-
If greater or less than, inform the user (too high, too low), inform them how many guesses remain. If any guesses remain, ask them to guess again. Otherwise, reveal the date and a consolation message, and exit.
-