This is a continuation of This task
Your master wants you to add/improve 5 points.
If a tag <br>
detected, make a new line when show_log
ex4) adam
& eve
registered, credits(later-explained) are enough
input: talk adam eve hi
input: talk eve adam I hate<br> you
input: show_log adam eve
OUTPUT: adam -> eve: hi
eve -> adam: I hate
you
There are NG (not good) words.
There are written in ngwords.txt
file, so read NG words from it (not hard-code).
If a NG word detected, mask it with *
ex5) adam
& eve
registered, credits(later-explained) are enough
ngwords.txt
twitter
2ch
University of Tokyo
command line
input: talk adam eve are you playing twitter or 5ch?
input: talk adam eve I am from the University of Tokyooo
input: show_log adam eve
OUTPUT: adam -> eve: are you playing * or 5ch?
adam -> eve: I am from the *oo
Define a new system; Room. All of the conversations is in a single room room can have 1-∞ users.
Room can be created with the command below:
create_room <room_name> <user_ID_0> <user_ID_1>...
no output required with this command.
ex6) adam
& eve
& ruby
& ai
registered
input: create_room gods adam eve ruby
Every user can talk in the room with talk
command.
talk <speaker_id> <room_name> <content>
The conversations in the room can be shown with show_log
.
If a user not in the room trying to talk, show Error: not in room
ex7) After ex6. Credits(later-explained) are enough
input: talk ruby gods I am 5 gods
input: talk eve gods im not
input: talk ai gods What about me?
OUTPUT: Error: not in room
input: talk ai room0 test
OUTPUT: Error: no user ID
input: show_log gods
OUTPUT: ruby -> gods: I am 5 gods
eve -> gods: im not
When there are only 2 users in the room,
- there are no command needed to create a room, the room automatically generated when they start talking
- The
talk
command don't have to be room-name, they can be also opponent user id - The automatically generated room will be
DM_<user_ID_0>_<user_ID_1>
In short, don't break ex2.
Newly define D
type and J
type of the users.
D
type users has a data called credits
They have to spend 1 credit to send 1 chat
J
type user has a data called earned
earned will increases by 1 every time when they got a message from D
type user in the room they are in.
Modify add_user
as
add_user <id(string)> <type>
ex8)
input: add_user adam d
input: add_user eve f
D
type user can gain credit with this command:
add_credit <user_ID> <amount>
No output required.
If minus number inputted, make it 0.
If this used for J
type, show Error: wrong type
What show_credit
command differs with the user's type.
show_credit <user_id>
-
If the user is
D
type, show remaining credits- The output is
<amount> remaining
- The output is
-
If the user is
J
type, show earned- The output is
<amount> earned
- The output is
Show output of only the number.
If the D
type user tried to talk with 0 credits, don't memorize the conversation, and show Error: not enough credit
ex9) after ex8
input: add_credit adam 1
input: add_credit eve 1
OUTPUT: ERROR: wrong type
input: show_credit adam
OUTPUT: 1
input: show_credit eve
OUTPUT: 0
input: talk adam eve hi
input: talk adam eve shall we talk?
OUTPUT: ERROR: not enough credit
input: show_log adam eve
OUTPUT: adam -> eve: hi