*Force book Java Fundamentals
Здравейте!
Имам 90/100 в Judge и вече не знам какво да правя. :)
https://pastebin.com/BpP9U9zV
Здравейте!
Имам 90/100 в Judge и вече не знам какво да правя. :)
https://pastebin.com/BpP9U9zV
For the tokens = input.split(" -> ") command when a given side doesn't exist, always check whether the target user doesn't exist if so move the user from the old group to the new one:
Your implementation:
if (!contains(forceBook, forceUser)) {
if (!forceBook.containsKey(forceSide)) {
forceBook.put(forceSide, new ArrayList<>());
}
forceBook.get(forceSide).add(forceUser);
System.out.printf("%s joins the %s side!%n", forceUser, forceSide);
Implentation that checks whether user is present when target side does not yet exist:
tokens = input.split(" -> ");
forceUser = tokens[0];
forceSide = tokens[1];
for (Map.Entry<String, List<String>> current : sides.entrySet()) {
if (current.getValue().contains(forceUser)) {
sides.get(current.getKey()).remove(forceUser);
break;
}
}
if (!sides.containsKey(forceSide)){
sides.putIfAbsent(forceSide, new ArrayList<>());
}
sides.get(forceSide).add(forceUser);
System.out.printf("%s joins the %s side!%n", forceUser, forceSide);
Again I have 90 / 100
:(
https://pastebin.com/6V0dTCGy
Колежке,
виж този вход:
Dark | Pesho
Pesho -> Lighter
Lumpawaroo
For the tokens = input.split(" -> ") command, even when the user is already present in the target group, the output message still has to be printed.
Try to change lines 35-43 from:
to:
For the input.split(" \\| "); command, try to separate the two validations to see whether a given group and user exist (lines 51-56):
Best,