示例#1
0
        public string ParseAllAuthors()
        {
            if (Authors is null || Authors.Count == 0)
            {
                return(string.Empty);
            }

            if (Authors.Count == 1)
            {
                var author      = Authors.First();
                var firstName   = !string.IsNullOrEmpty(author.FirstName) ? $" {author.FirstName}" : string.Empty;
                var fathersName = !string.IsNullOrEmpty(author.FathersName) ? $" {author.FathersName}" : string.Empty;
                var lastName    = !string.IsNullOrEmpty(author.LastName) ? $"{author.LastName}" : string.Empty;

                return($" / {lastName}{firstName}{fathersName}");
            }

            var result = " / ";

            for (int i = 0; i < Authors.Count - 1; i++)
            {
                var author = Authors[i];
                result += $"{ConvertAuthorToString(author)}, ";
            }

            var lastAuthor = Authors.Last();

            result += $"{ConvertAuthorToString(lastAuthor)}";

            return(result);
        }
示例#2
0
文件: Book.cs 项目: Sistely/SWII
        public string getAuthorNames()
        {
            string aux = "";

            foreach (Author a in Authors)
            {
                aux += a.Name;

                if (a != Authors.Last())
                {
                    aux += ",";
                }
            }
            return(aux);
        }
示例#3
0
文件: Book.cs 项目: Sistely/SWII
        public override string ToString()
        {
            string lista2 = "";

            foreach (Author a in Authors)
            {
                lista2 += $"[name={a.Name},email={a.Email},gender={a.Gender}]";

                if (a != Authors.Last())
                {
                    lista2 += ",";
                }
            }

            string lista1 = "Book[" + Name + ",authors={Authors" + lista2 + "},price=" + Price + ",qty=" + Qty + "]";

            return(lista1);
        }
示例#4
0
        public override string ToString()
        {
            string authorList = "";

            foreach (Author a in Authors)
            {
                authorList += $"[name={a.Name},email={a.Email},gender={a.Gender}]";

                if (a != Authors.Last())
                {
                    authorList += ",";
                }
            }

            string stringFormatada = "Book[" + Name + ",authors={Authors" + authorList + "},price=" + Price + ",qty=" + Qty + "]";

            return(stringFormatada);
        }
示例#5
0
        public string getAuthorNames()
        {
            string author = "";

            foreach (Author a in Authors)
            {
                author += a.Name;

                if (a == Authors.Last())
                {
                }

                else
                {
                    author += ",";
                }
            }
            return(author);
        }
示例#6
0
        private IReadOnlyCollection <object> BuildDescriptionItems()
        {
            var displayItems = new List <object>();

            foreach (var author in Authors)
            {
                displayItems.Add(author);
                if (author != Authors.Last())
                {
                    displayItems.Add(", ");
                }
            }
            if (Name != null)
            {
                displayItems.Insert(0, this);
                displayItems.Insert(1, " (");
                displayItems.Add(")");
            }
            displayItems.Insert(0, "by ");

            return(displayItems);
        }
示例#7
0
        public override string ToString()
        {
            string authors = "";

            foreach (Author a in Authors)
            {
                authors = authors + $"[name={a.Name},email={a.Email},gender={a.Gender}]";

                if (a == Authors.Last())
                {
                }

                else
                {
                    authors += ",";
                }
            }

            string stringFinal = "Book[" + Name + ",authors={Author" + authors + "},price=" + Price + ",qty=" + Qty + "]";

            return(stringFinal);
        }