Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _27._08._2019.CSharp
- {
- class Program
- {
- class Email
- {
- public String Subject { get; private set; }
- public String Sender { get; private set; }
- public String Body { get; private set; }
- public Email(String subject, String sender, String body)
- {
- this.Subject = subject; this.Sender = sender; this.Body = body;
- }
- }
- interface IFilter
- {
- List<String> CreateNewEmailList(List<Email> email);
- List<String> CreateSendersList(List<Email> email);
- }
- class SpamFilter : IFilter
- {
- private List<String> spamKeywords = new List<string>();
- public void AddSpamKeyword(String spamKeyword)
- {
- spamKeywords.Add(spamKeyword);
- }
- public List<String> CreateNewEmailList(List<Email> email)
- {
- List<string> newEmailList = new List<string>();
- for (int i = 0; i < email.Count(); i++)
- {
- for (int j = 0; j < spamKeywords.Count(); i++)
- {
- if (email[i].Subject.Contains(":)") || email[i].Body.Contains(spamKeywords[j]))
- {
- newEmailList.Add(email[i].Body); //misli li se samo na spam sadrzaj ili na spam mail u globalu?
- }
- }
- }
- return newEmailList;
- }
- public List<String> CreateSendersList(List<Email> email)
- {
- List<String> sendersList = new List<string>();
- for (int i = 0; i < email.Count(); i++)
- {
- for (int j = 0; j < spamKeywords.Count(); i++)
- {
- if (email[i].Subject.Contains(":)") || email[i].Body.Contains(spamKeywords[j]))
- {
- sendersList.Add(email[i].Sender);
- }
- }
- }
- return sendersList;
- }
- }
- int EndsWithDomain(List<Email> email)
- {
- int counter = 0;
- for(int i = 0; i < email.Count(); i++)
- {
- if (email[i].Sender.Contains("gmail.com"))
- {
- counter++;
- }
- }
- return counter;
- }
- static void Main(string[] args)
- {
- List<Email> discountOffers = mailClient.FetchNewMessages();
- int totalEmails = discountOffers.Count();
- EndsWithDomain(discountOffers);
- int newTotal = discountOffers.Count();
- Console.WriteLine("Udio emailova koji je dosao s domene gmail.com je ", (newTotal/totalEmails)*100 , " %.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement