Help with Classes Exercise
I'm confused.. here's the homework;
Note: all of this has to be done in classes.
Define the class Lock. The data members should be private so that the codes may only be altered via the interface functions.
Write a program called locktest.cpp which declares a lock-type variable, initializes its secret code to some value, then enters a loop in which it asks the user for a code to dial and states whether the lock is open or not.
This was provided by the teacher:
Member Functions (public)
Void setCode(int newCode) //Sets the secret code to newcode
void dialcode(int combo) //Dials combo on the lock
bool isopen() //Returns true if lock is open and false if not.
int code //secret code that opens lock
int setting //The code that has been dialed on lock. If setting matches code, the lock is considered open. Otherwise, lock is closed.
Can anyone give me hints on where to get started?
thanks in advance.