Computers and Technology

Create a Java project called Padlock. java with the given information 1. public Padlock​(int n1,
int n2,
int n3)
Constructs a padlock with the given combination. This constructor does NOT verify that the given combination is valid, in the sense described above. A lock with an invalid combination will still behave according to this specification in every respect; however it may be impossible to unlock it following the steps in the package directions.
Initially, the lock is open and the dial is at 0, disc 2 is at TOOTH degrees rotation, and disc 1 is at 2 * TOOTH degrees rotation, regardless of the given combination.
2. public void randomizePositions​(java. util. Random rand)
Set the three discs to random, valid positions.
3. public void setPositions​(int n1, int n2, int n3)
Sets the positions of the three discs to given angles, as closely as possible while ensuring the positions are valid. Disc 3 is always set to the given angle n3. If the given angle n2 is within n3 plus or minus the tooth width, then the disc 2 position will be set to n3 + the tooth width. Similarly, if n1 is within the new disc 2 position plus or minus the tooth width, then disc 1 will be set to the new disc 2 position + the tooth width. All values will be normalized to be between 0 and 359, inclusive.
4. public void turnLeftTo​(int number)
Turns the dial (disc 3) counterclockwise until its position is the given number.
5. public void turnRightTo​(int number)
Turns the dial (disc 3) clockwise until its position is the given number.
6. public void turn​(int degrees)
Turns the dial (disc 3) the given number of degrees, where a positive number represents a counterclockwise rotation and a negative number represents a clockwise rotation.
7. public int getDiscPosition​(int which)
Returns the current position of the given disc (1, 2, or 3, where disc 3 is the front disc attached to the dial). The value returned is always normalized to be between 0 and 359, inclusive. If the argument is not equal to 1, 2, or 3, the method returns -1.
8. public boolean isAligned()
Returns true if all three discs are aligned, that is, for all discs the current position is equal to the offset.
9. public void open()
Opens the lock, if possible. Does nothing unless isAligned is true.
10. public void close()
Closes the lock, whether or not the discs are aligned.
11. public boolean isOpen()
Determines whether the lock is currently open.
12. public static final int TOOTH
Width of the teeth on each disc in the mechanism, expressed in degrees of rotation.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 14:30, leannamat2106
Asoftware program that includes tools for entering, editing, and formatting text and graphics is called a word processing program. true or false?
Answers: 1
image
Computers and Technology, 22.06.2019 01:30, luje
Imagine that you have a friend who is starting a small business and is interested in using social media to spread the word. he is not certain that it is a good move, and has come to you for . would you advise him to use social media to advertise his business? why or why not? support you answer with information from the text.
Answers: 1
image
Computers and Technology, 22.06.2019 05:20, ashcormu11
Write a program called assignment3 (saved in a file assignment3.java) that computes the greatest common divisor of two given integers. one of the oldest numerical algorithms was described by the greek mathematician, euclid, in 300 b. c. it is a simple but very e↵ective algorithm that computes the greatest common divisor of two given integers. for instance, given integers 24 and 18, the greatest common divisor is 6, because 6 is the largest integer that divides evenly into both 24 and 18. we will denote the greatest common divisor of x and y as gcd(x, y). the algorithm is based on the clever idea that the gcd(x, y) = gcd(x ! y, y) if x > = y and gcd(x, y) = gcd(x, y ! x) if x < y. the algorithm consists of a series of steps (loop iterations) where the “larger” integer is replaced by the di↵erence of the larger and smaller integer. this continues until the two values are equal. that is then the gcd.
Answers: 3
image
Computers and Technology, 22.06.2019 07:30, alexandramendez0616
Jasper and samantha are in a robotics competition. the guidelines state that the robots should be able to move a 10-gram weight at least 2 meters and turn in a circle. jasper and samantha have already built the robot. which step of the design process should they follow next to decide whether their robot meets the minimum criteria for the competition?
Answers: 1
Do you know the correct answer?
Create a Java project called Padlock. java with the given information 1. public Padlock​(int n1,

Questions in other subjects:

Konu
Mathematics, 29.10.2019 16:31
Konu
Social Studies, 29.10.2019 16:31