Някой има ли решението на тази задача от темата Обекти и класове?

1.Teamwork Projects

It's time for the teamwork projects and you are responsible for gathering the teams. First you will receive an integer - the count of the teams you will have to register. You will be given a user and a team, separated with “-”.  The user is the creator of the team. For every newly created team you should print a message:

"Team {teamName} has been created by {user}!".

Next, you will receive а user with a team, separated with "->", which means that the user wants to join that team. Upon receiving the command: “end of assignment”, you should print every team, ordered by the count of its members (descending) and then by name (ascending). For each team, you have to print its members sorted by name (ascending). However, there are several rules:

  • If а user tries to create a team more than once, a message should be displayed:
    • "Team {teamName} was already created!"
  • A creator of a team cannot create another team – the following message should be thrown:
    • "{user} cannot create another team!"
  • If а user tries to join a non-existent team, a message should be displayed:
    • "Team {teamName} does not exist!"
  • A member of a team cannot join another team – the following message should be thrown:
    • "Member {user} cannot join team {team Name}!"
  • In the end, teams with zero members (with only a creator) should disband and you have to print them ordered by name in ascending order.
  •  Every valid team should be printed ordered by name (ascending) in the following format:

"{teamName}

- {creator}

-- {member}…"

Examples

Input

Output

Comments

2

John-PowerPuffsCoders

Tony-Tony is the best

Peter->PowerPuffsCoders

Tony->Tony is the best

end of assignment

Team PowerPuffsCoders has been created by John!

Team Tony is the best has been created by Tony!

Member Toni cannot join team Tony is the best!

PowerPuffsCoders

- John

-- Peter

Teams to disband:

Tony is the best

Tony created a team, which he attempted to join later and this action resulted in throwing a certain message. Since nobody else tried to join his team, the team had to disband.

3

Tanya-CloneClub

Helena-CloneClub

Tedy-SoftUni

George->softUni

George->SoftUni

Tatyana->Leda

John->SoftUni

Cossima->CloneClub

end of assignment

Team CloneClub has been created by Tanya!

Team CloneClub was already created!

Team SoftUni has been created by Tedy!

Team softUni does not exist!

Team Leda does not exist!

SoftUni

- Tedy

-- George

-- John

CloneClub

- Tanya

-- Cossima

Teams to disband:

Note that when a user joins a team, you should first check if the team exists and then check if the user is already in a team:

 

Tanya has created CloneClub, then she tried to join a non-existent team and the concrete message was displayed.