C++ please, Specify, design, and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob, with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we'll call x, y, z. To open the lock, you must turn the knob clockwise at least one entire revolution, stopping with x at the top; then turn the knob counter-clockwise; stopping the second time that y appears at the top; finally turn the knob clockwise again, stopping the next time the z appears at the top. At this point the lock will be open. Your lock class should have a constructor that initializes the three-number combination (use 0,0,0 for default arguments). Also provide member functions: a. To alter the lock's combination b.To turn the knob in a given direction until a specified number appears on top c. To close the lock d. To attempt to open the lock e. To inquire the status of the lock (open or shut) f. To tell you what number is currently at the top You must use the class as defined on the back side of this paper for lock then derive a class object called safe that you will use in main. You are not allowed to change member function names or formats. You may however add data members to the private section as needed (no data members are to be made public).   class lock { private: // THIS IS THE ONLY PLACE YOU MAY ADD VARIABLES bool open_lock(); protected: lock (int =0, int =0, int =0); void turn knob(int direction); void close_lock()l; bool lock status(); void change combo(); int num_at_top(); };

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

C++ please,

Specify, design, and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob, with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we'll call x, y, z. To open the lock, you must turn the knob clockwise at least one entire revolution, stopping with x at the top; then turn the knob counter-clockwise; stopping the second time that y appears at the top; finally turn the knob clockwise again, stopping the next time the z appears at the top. At this point the lock will be open.

Your lock class should have a constructor that initializes the three-number combination (use 0,0,0 for default arguments). Also provide member functions:

a. To alter the lock's combination

b.To turn the knob in a given direction until a specified number appears on top

c. To close the lock

d. To attempt to open the lock

e. To inquire the status of the lock (open or shut)

f. To tell you what number is currently at the top

You must use the class as defined on the back side of this paper for lock then derive a class object called safe that you will use in main. You are not allowed to change member function names or formats. You may however add data members to the private section as needed (no data members are to be made public).

 

class lock

{

private:

// THIS IS THE ONLY PLACE YOU MAY ADD VARIABLES

bool open_lock();

protected:

lock (int =0, int =0, int =0);

void turn knob(int direction);

void close_lock()l;

bool lock status();

void change combo();

int num_at_top();

};

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT