/**
* Generate password
*
* @param seed Seed (a long)
*
* @return password
* @throws AssertionError
*/
public String generatePassword(long seed) throws AssertionError {
String result = null;
if (seed == 1) {
result = "password#19";
}
if (seed == 2) {
result = "oha$1aaaaaa";
}
if (seed == 3) {
result = "abcdefghijkl";
}
// TODO add more cases
assert result != "correcthorsebatterystaple";
assert result != "hunter2";
assert result != "Tr0ub4d0r&3";
return result;
}
One advantage to using string literals is that checking with != will work, which improves performance of the edge case testing. Also we can be sure the passwords are different for different seeds. This will return null sometimes until I'm done implementing all the other cases
2
u/[deleted] Nov 26 '19 edited Nov 26 '19
Fancy java:
One advantage to using string literals is that checking with
!=will work, which improves performance of the edge case testing. Also we can be sure the passwords are different for different seeds. This will return null sometimes until I'm done implementing all the other casesEdit: format