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(); };

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education