Loading...
SummerEverdeen avatar SummerEverdeen 4 Точки

05. Teamwork Projects (Objects and Classes Exercise)

Здравейте,

 

Последният тест ми дава грешен отговор със следното съобщение: "The process executing your submission for this test may not have received the output successfully. Please try to submit again the same solution. If the result does not change, then search the error in the submission itself."

 

Не успявам да открия грешката си. Моля за помощ :)

 

Това е кодът ми: https://pastebin.com/tinSHZZx

 

Това е условието: 

 

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

Didi-PowerPuffsCoders

Toni-Toni is the best

Petq->PowerPuffsCoders

Toni->Toni is the best

end of assignment

Team PowerPuffsCoders has been created by Didi!

Team Toni is the best has been created by Toni!

Member Toni cannot join team Toni is the best!

PowerPuffsCoders

- Didi

-- Petq

Teams to disband:

Toni is the best

Toni 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

Tatyana-CloneClub

Helena-CloneClub

Trifon-SoftUni

Pesho->softUni

Pesho->SoftUni

Tatyana->Leda

PeshO->SoftUni

Cossima->CloneClub

end of assignment

Team CloneClub has been created by Tatyana!

Team CloneClub was already created!

Team SoftUni has been created by Trifon!

Team softUni does not exist!

Team Leda does not exist!

SoftUni

- Trifon

-- Pesho

-- PeshO

CloneClub

- Tatyana

-- 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:

 

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

0
C# Fundamentals 16/02/2021 20:51:05
Axiomatik avatar Axiomatik 2422 Точки

Looks OK from what I can see, except that your members property is set up like a private field and does not have any getters nor setters:

            public string Name { get; set; }
            public string Creator { get; set; }
 
            public List<string> members;
 
            public Team (string name, string creator)
            {
                this.Name = name;
                this.Creator = creator;
 
                members = new List<string>();             
            }

Should be:

    class Team
    {
        public string Creator { get; set; }

        public string TeamName { get; set; }

        public List<string> Members { get; set; }

        public Team(string creator, string teamName)
        {
            Creator = creator;
            TeamName = teamName;
            Members = new List<string>();
        }
    }

 

With private field members:

    class Team
    {
        private List<string> members;

        public Team(string creator, string teamName)
        {
            Creator = creator;
            TeamName = teamName;
            Members = new List<string>();
        }

        public string Creator { get; set; }

        public string TeamName { get; set; }

        public List<string> Members
            {
                get
                {
                    return this.members;
                }
                private set
                {
                    this.members = value;
                }
            }
    }

 

0
17/02/2021 08:36:03
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.