Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Assignment Description. Design a class called ComboLock that works like the 3-number combinationn lock in a gym locker. A combination lock is opened with

c++
image text in transcribed
Assignment Description. Design a class called ComboLock that works like the 3-number combinationn lock in a gym locker. A combination lock is opened with a simple procedure: turn the lock's dial to the right until you reach the first number in the combination. Then turn the lock to the left until you reaclh the second number. Finally, turn to the right ul the third number is reached. If the three numbers were correct, the lock will open. A ComboLock object is constructed with three integers from 0-39 representing the combination needed to unlock the object. Create a new C++ program and make a class named ComboLock. Design the class to these specifications: . You w need three member variables to represent the three integers needed to open the lock. Choose an appropriate type and names for these variables. Make sure your member variables are private and NOT static. 2. Add a fourth member variable to represent the current position of the lock's dial (the part that spins) 3. Add a constructor that takes three values for the lock's combination and initializes the member variables accordingly. The dial position should start at 0. You may assume the combination numbers are always between 0 and 39 4. Add an accessor method getDialPosition(, which returns the current dial position of the lock 5. Add these methods to manipulate the lock (a) void reset): set the dial position back to 0 and start the unlocking procedure over again (b) void turneft int ticks): tun the dial to the left by the specified number of ticks from the current position. The ticks parameter is NOT the number you wish to turn to-it is how many positions to move from where you currently are. Example: if the current position is at 10, then turnLeft (10) would turn the dial to 20 (c) void turnRight (int ticks) likewise, turns the dial to the right by the specified number of ticks (d) boolean open(): attempts to open the lockI the user's mostecent turnRight, turnLeft, turnRight methods entered the correct three combination numbers, then the method returns true and resets the lock. Otherwise the method returns false and resets the lock. i. This method is one of the harder parts of the lab. You will need to add member variables to the ComboLock class to help you with this method. You will need some way of remembering all three numbers that the user spun the lock to. You will also need to make sure the user spun the correct direction each time, not solely that they landed on the right number class declaration itself Include a one-sentence each method parameter, and a return entry if the method has a on-void return value ally, add documentation comments to each public method of your ComboLock class, as well as the e-sentence description of what the method does, plus entries for

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

1. What might have led to the misinformation?

Answered: 1 week ago