private Task GetTaskFromUserInputs (out bool success) { success = false; Task newTask = new Task(); newTask.Description = ReadDescription(out success); if (!success) return null; newTask.DateTime = ReadDate(out success); if (!success) return null; newTask.Priority = ReadPriority(out success); return null; }
private ShoppingItem ReadInput (out bool success) { success = false; ShoppingItem item = new ShoppingItem(); item.Description = ReadDescription(out success); if (!success) return null; item.Amount = ReadAmount(out success); if (!success) return null; item.Unit = ReadUnit(out success); return item;
using System.Text; using System.Threading.Tasks; namespace FriendlyReminder { class Task { DateTime date; private string description; PriorityType priority; public string Description { get { return description; } set { description = value; } } public string DateTime; public PriorityType Priority { get { return priority; } set { priority = value; } } public DateTime Date { get { return date; } set { date = value; } } public Task (DateTime date, PriorityType priority, string description) { this.date = date; this.priority = priority; this.description = description; } public string GetPriorityString() { return string.Empty; } public string GetTimeString() { return date.ToShortDateString(); } public string ToString() { return $"{date.ToShortDateString(),-12}" + $"{GetTimeString(),-7}" + $"{GetPriorityString(),-16}" + $"{description}"; } } }
newTask.Priority = ReadPriority(out success); return newTask; // ignoring success status
newTask.Priority = ReadPriority(out success); if (!success) return null; return newTask; // returning the Task instance only on success
Task
System.Threading.Tasks
FriendlyReminder.Task
Task newTask = new Task();
Task newTask = new Task(DateTime.MinValue, PriorityType.NotUrgent, "Default task");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)