internal static int CalcNumberOfChars(Newspaper newspaper) { int sum = 0; for (int i = 0; i < newspaper.GetStories().Length; i++) { sum = sum + newspaper.GetStories()[i].GetTitle().Length + newspaper.GetStories()[i].GetBody().Length; } return(sum); }
internal static int CalcNumberOfChars(Newspaper newspaper) { foreach (Story story in newspaper.GetStories()) { numberOfChars = numberOfChars + story.m_body.Length; } return(numberOfChars); }
static void Main(string[] args) { Story politicStory = new Story("New President", "Kanye West is the new President of the USA", "column"); Story healthStory = new Story("Coronavirus", "Coronavirus is defeated", "research paper"); Story gossipStory = new Story("Celebrity in Love", "Madonna has a new boyfriend", "review"); string[] _stories = { "politicStory", "healthStory", "gossipStory" }; for (int i = 0; i < _stories.Length; i++) { Console.WriteLine(_stories[i]); } Newspaper n = new Newspaper(); float newPrice = 50; n.SetPrice(newPrice); n.GetPrice(); n.SetStories(_stories); n.GetStories(); n.Read(); Console.WriteLine(n); }