Nov-07-2020, 05:45 PM
Hi guys I would love to get some help on the following problem. :)
List Manipulator
Our player is having trouble with his friend list and some guys are disappearing without a reason so he asks you to create a program that will figure out what is going on and at the end will bring him a report.
On the first line you will receive all his friends separated by ", ". On the next lines until the "Report" command you will receive commands. The commands could be:
• Blacklist {name}
• Find the name in the friend list and change it to "Blacklisted" and print on the console:
• "{name} was blacklisted."
• If the name is not in the friend list print:
• "{name} was not found."
• Error {index}
• Check if the username at the given index is not "Blacklisted" or "Lost". If it isn't, change the username to "Lost" and print on the console:
• "{name} was lost due to an error."
• Change {index} {newName}
• Check if the user at index position is in range of the array. If he is, change the current username with the new one and print on console:
• "{currentName} changed his username to {newName}."
After you receive "Report" print on the console the count of blacklisted names, the count of lost names, and the friend list separated by a single space.
Input
• The first input line will contain the usernames that need to be stored.
• On the next input lines until "Report" you will receive commands.
Output
• The output should be in the following format:
• "Blacklisted names: {blacklistedNamesCount}"
• "Lost names: {lostNamesCount}"
• "{name1} {name2} .. {nameN}"
List Manipulator
Our player is having trouble with his friend list and some guys are disappearing without a reason so he asks you to create a program that will figure out what is going on and at the end will bring him a report.
On the first line you will receive all his friends separated by ", ". On the next lines until the "Report" command you will receive commands. The commands could be:
• Blacklist {name}
• Find the name in the friend list and change it to "Blacklisted" and print on the console:
• "{name} was blacklisted."
• If the name is not in the friend list print:
• "{name} was not found."
• Error {index}
• Check if the username at the given index is not "Blacklisted" or "Lost". If it isn't, change the username to "Lost" and print on the console:
• "{name} was lost due to an error."
• Change {index} {newName}
• Check if the user at index position is in range of the array. If he is, change the current username with the new one and print on console:
• "{currentName} changed his username to {newName}."
After you receive "Report" print on the console the count of blacklisted names, the count of lost names, and the friend list separated by a single space.
Input
• The first input line will contain the usernames that need to be stored.
• On the next input lines until "Report" you will receive commands.
Output
• The output should be in the following format:
• "Blacklisted names: {blacklistedNamesCount}"
• "Lost names: {lostNamesCount}"
• "{name1} {name2} .. {nameN}"