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;
- namespace BoardR
- {
- class BoardItem
- {
- string title;
- DateTime dueDate;
- StatusStages status = StatusStages.Open;
- List<EventLog> historyEvents = new List<EventLog>();
- public StatusStages Status
- {
- get
- {
- return this.status;
- }
- set
- {
- this.status = value;
- }
- }
- public DateTime DueDate
- {
- get { return this.dueDate; }
- set { this.dueDate = value; }
- }
- public string Title
- {
- get
- {
- return this.title;
- }
- set
- {
- // validate
- if (ValidateTitle(title) && ValidateDate(dueDate))
- {
- this.title = value;
- }
- }
- }
- public BoardItem(string title, DateTime dueDate)
- {
- this.Title = title; // ТУК НА МЕН ВИНАГИ МИ ДАВА exeption ?!??!?!?!??!
- this.DueDate = dueDate;
- this.historyEvents.Add(new EventLog("Board item was created"));
- }
- public void AdvanceStatus()
- {
- if (this.status != StatusStages.Verified)
- this.status++;
- }
- public void RevertStatus()
- {
- if (this.status != StatusStages.Open)
- this.status--;
- }
- public void AddingItems(string title, DateTime dueDate)
- {
- EventLog eventItself = new EventLog(title);
- historyEvents.Add(eventItself);
- }
- public string ViewHistory()
- {
- return string.Join("\n", this.historyEvents.Select(x => x.ViewInfo()));
- }
- public string ViewInfo()
- {
- return $"'{title}', [{status}|{dueDate.ToString("dd-MM-yyyy")}]";
- }
- private static bool ValidateDate(DateTime dueDate)
- {
- if (dueDate <= DateTime.Now)
- {
- throw new ArgumentException("Due date cannot be in the past");
- }
- else
- {
- return true;
- }
- }
- private static bool ValidateTitle(string itemTitle)
- {
- if (string.IsNullOrEmpty(itemTitle))
- {
- throw new ArgumentException("Title cannot be null or empty");
- }
- else if (itemTitle.Length < 5 || itemTitle.Length > 30)
- {
- throw new ArgumentException("Title must be between 5 and 30 chars");
- }
- else
- {
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement