Софтуерно Инженерство
Loading...
+ Нов въпрос
AleksandarG avatar AleksandarG 1 Точки

задача Inbox Manager final exam JS Fundamentals

Някой има ли насоки как да се реши задачата:

ето до къде стигнах аз:

 

https://pastebin.com/uBwkyqLs

 

 

Create a program that manages users and Emails sent by users. You need to keep information about their username and their sent Emails. The Emails are represented as strings. You will be receiving lines with commands separated by "->" until you receive the "Statistics" command. There are three possible commands:

  • "Add->{username}":

    • Check if the username exists and if it does print:

"{username} is already registered"

If it doesn’t exist, then add the user to the collection of users.

  • "Send->{username}->{Email}"

    • Add the {Email} to the {username}'s collection of sent Emails.

  • "Delete->{username}":

    • Delete the given user, if he exists. If the user doesn’t exist, print:

"{username} not found!"

In the end, you have to print the count of users, each user with his/her Emails. Users need to be sorted in descending order by the count of sent Emails and then by their username in ascending order in the following format:

Users count: {count}

{username}

- {Email1}

- {Email2}

- {Emailn}

Input

  • You will be receiving lines until you receive the "Statistics" command.

  • The commands will be in the format described above.

Output

  • Print the collection in the format described above after the "Statistics" command.

Add->Mike

Add->George

Send->George->Hello World

Send->George->Some random test mail

Send->Mike->Hello, do you want to meet up tomorrow?

Send->George->It would be a pleasure

Send->Mike->Another random test mail

Statistics
 

Users count: 2

George

- Hello World

- Some random test mail

- It would be a pleasure

Mike

- Hello, do you want to meet up tomorrow?

- Another random test mail

Comments

 

First we receive our users. Since they are not already in our collection, we add them. Then they start sending emails and in the end we print the output in the described format.

 

 

 

Add->Mike

Add->George

Send->George->Hello World

Send->George->Your loan is overdue

Add->Mike

Send->Mike->Hello, do you want to meet up tomorrow?

Delete->Peter

Send->George->I'm busy

Send->Mike->Another random test mail

Delete->George

Statistics

Mike is already registered

Peter not found!

Users count: 1

Mike

- Hello, do you want to meet up tomorrow?

- Another random test mail

Тагове:
0
Fundamentals Module
christoff avatar christoff 2 Точки

Далеч не е най-доброто решение, но ми докара 100 точки. https://pastebin.com/T8C46AE4
Особено 2-та forEach-a ...

0
08/12/2019 12:44:13
AleksandarG avatar AleksandarG 1 Точки

благодаря

0