For this program, you will create a class modeled on a real-world combination lock. A combination lock (like the one shown) allows a person to turn the dial counter-clockwise to select the first number, then turn the dial clockwise to select the second number, and final turn the dial counter-clockwise to select the third number. If the numbers were selected in the correct order and match the lock's combination, then the lock will open. The lock you will model will have the numbers 0 through 39 with a three-number combination.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Hi, can you help me here please?
For this program, you will create a class modeled on a real-world
combination lock. A combination lock (like the one shown) allows a
person to turn the dial counter-clockwise to select the first number,
then turn the dial clockwise to select the second number, and finally
turn the dial counter-clockwise to select the third number. If the
numbers were selected in the correct order and match the lock's
20
combination, then the lock will open. The lock you will model will
have the numbers 0 through 39 with a three-number combination.
The class must be named Combolock (in a file named
Combolock.java) and must contain the following in its design:
1. A public constructor that accepts three int arguments as its combination.
• Ifa number less than 0 is supplied for any argument, default that number to 0.
• Ifa number greater than 39 is supplied for any argument, default that number to 39.
2. A public void method named reset that accepts no arguments.
• This method should set the dial's current position back to zero and “forget" the numbers
that were previously selected by the dial.
3. A public void method named turnClockwise that accepts one int argument.
• The int argument is how many numbers the dial is turned clockwise (forward).
• Be sure to not let the dial exceed 39. If the dial is turned past 0, it continues from 39.
4. A public void method named turnCounterClockwise that accepts one int argument.
• The int argument is how many numbers the dial is turned counterclockwise (backwards).
• Be sure to not let the dial go below 0. If the dial is turned past 39, it continues from 0.
5. A public method named open that accepts no arguments.
This method returns a boolean: true if the correct combination was entered, false if the
incorrect combination was entered.
You may include any private methods and private fields as you deem necessary, but do not include any
additional public members. The class will need to keep track of the lock's correct combination, the
combination that was entered by calling the turnClockwise and turnCounterClockwise methods, and
what number the dial is currently set to.
Transcribed Image Text:For this program, you will create a class modeled on a real-world combination lock. A combination lock (like the one shown) allows a person to turn the dial counter-clockwise to select the first number, then turn the dial clockwise to select the second number, and finally turn the dial counter-clockwise to select the third number. If the numbers were selected in the correct order and match the lock's 20 combination, then the lock will open. The lock you will model will have the numbers 0 through 39 with a three-number combination. The class must be named Combolock (in a file named Combolock.java) and must contain the following in its design: 1. A public constructor that accepts three int arguments as its combination. • Ifa number less than 0 is supplied for any argument, default that number to 0. • Ifa number greater than 39 is supplied for any argument, default that number to 39. 2. A public void method named reset that accepts no arguments. • This method should set the dial's current position back to zero and “forget" the numbers that were previously selected by the dial. 3. A public void method named turnClockwise that accepts one int argument. • The int argument is how many numbers the dial is turned clockwise (forward). • Be sure to not let the dial exceed 39. If the dial is turned past 0, it continues from 39. 4. A public void method named turnCounterClockwise that accepts one int argument. • The int argument is how many numbers the dial is turned counterclockwise (backwards). • Be sure to not let the dial go below 0. If the dial is turned past 39, it continues from 0. 5. A public method named open that accepts no arguments. This method returns a boolean: true if the correct combination was entered, false if the incorrect combination was entered. You may include any private methods and private fields as you deem necessary, but do not include any additional public members. The class will need to keep track of the lock's correct combination, the combination that was entered by calling the turnClockwise and turnCounterClockwise methods, and what number the dial is currently set to.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY