Counter.cs 896 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApplication6.SecondPhase
  7. {
  8. class Counter
  9. {
  10. public DateTime datetime;
  11. public int count;
  12. public List<String> addresses = new List<string>();
  13. public Counter(DateTime datetime)
  14. {
  15. this.datetime = new DateTime(datetime.Year, datetime.Month, datetime.Day, datetime.Hour, 0, 0);
  16. this.count = 0;
  17. }
  18. public void increase(String address)
  19. {
  20. if (!addresses.Contains(address))
  21. {
  22. addresses.Add(address);
  23. count = count + 1;
  24. }
  25. }
  26. public Boolean isTheHour(DateTime time)
  27. {
  28. return (datetime == new DateTime(time.Year, time.Month, time.Day, time.Hour, 0, 0));
  29. }
  30. }
  31. }