Question: Exercise 3 : The StringVault Class - Working with strings in Java Note: Copy and paste the terminal output of your programs in your lab
Exercise : The StringVault Class Working with strings in Java
Note: Copy and paste the terminal output of your programs in your lab report as evidence of testing
your methods with different inputs.
Driver: Student B
point Implement and test a new Java class called StringVault.
Each instance of StringVault should have a private field secret for a string value that should
be accessible only to methods that can provide the password another string stored in
another private field password of the StringVault class. The password and secret should be
set by the constructor at the time the StringVault instance is created.
Provide public methods getSecret and setSecret for respectively accessing or replacing
the value of the secret field.
Each of these methods getSecret and setSecret should have an additional parameter for
the password. If the password doesn't match, getSecret should
return null and setSecret should have no side effect.
Driver: Student A
point Create a user program to test the StringVault class using the following steps:
Call setSecret with an incorrect password.
Confirm that the secret is not updated.
Call setSecret again with a correct password.
Confirm that the secret is updated this time.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
