Initial commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/.vs
|
||||
/bin
|
||||
/obj
|
10
Activities.csproj
Normal file
10
Activities.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
25
Activities.sln
Normal file
25
Activities.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34701.34
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Activities", "Activities.csproj", "{D81F6378-2184-4380-AF69-D03738C63DA6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D81F6378-2184-4380-AF69-D03738C63DA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D81F6378-2184-4380-AF69-D03738C63DA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D81F6378-2184-4380-AF69-D03738C63DA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D81F6378-2184-4380-AF69-D03738C63DA6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0D40D0B7-0470-4089-948E-E14CE210C76F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
24
Activity.cs
Normal file
24
Activity.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace Activities
|
||||
{
|
||||
public class Activity(string title, DateOnly date, string description)
|
||||
{
|
||||
private readonly string title = title;
|
||||
private readonly DateOnly date = date;
|
||||
private readonly string description = description;
|
||||
|
||||
public string GetTitle()
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public DateOnly GetDate()
|
||||
{
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
}
|
||||
}
|
51
Invitation.cs
Normal file
51
Invitation.cs
Normal file
@ -0,0 +1,51 @@
|
||||
namespace Activities
|
||||
{
|
||||
public class Invitation
|
||||
{
|
||||
public static string GetValue(string prompt)
|
||||
{
|
||||
Console.Write(prompt);
|
||||
string? value = Console.ReadLine();
|
||||
if (value == null)
|
||||
{
|
||||
Console.WriteLine("No input provided.");
|
||||
value = GetValue(prompt);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DateOnly GetDate(string prompt)
|
||||
{
|
||||
string value = GetValue(prompt);
|
||||
DateOnly date;
|
||||
try
|
||||
{
|
||||
date = DateOnly.Parse(value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Invalid date provided.");
|
||||
date = GetDate(prompt);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
public static bool GetResponse(string prompt)
|
||||
{
|
||||
string value = GetValue(prompt);
|
||||
if (value.Equals("y", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (value.Equals("n", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid response provided.");
|
||||
return GetResponse(prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
Person.cs
Normal file
18
Person.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Activities
|
||||
{
|
||||
public class Person(string name, string email)
|
||||
{
|
||||
private readonly string name = name;
|
||||
private readonly string email = email;
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public string GetEmail()
|
||||
{
|
||||
return this.email;
|
||||
}
|
||||
}
|
||||
}
|
39
Program.cs
Normal file
39
Program.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
namespace Activities
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine("Creating a new invitation. Please enter your details.");
|
||||
string organisorName = Invitation.GetValue("Your name: ");
|
||||
string organisorEmail = Invitation.GetValue("Your email: ");
|
||||
Person organisor = new(organisorName, organisorEmail);
|
||||
Console.Clear();
|
||||
Console.WriteLine("Enter activity details.");
|
||||
string activityTitle = Invitation.GetValue("Activity title: ");
|
||||
DateOnly activityDate = Invitation.GetDate("Activity date (DD/MM/YYYY): ");
|
||||
string activityDescription = Invitation.GetValue("Activity description: ");
|
||||
Activity activity = new(activityTitle, activityDate, activityDescription);
|
||||
Console.Clear();
|
||||
List<Person> invitees = [];
|
||||
bool addInvitee = true;
|
||||
while (addInvitee)
|
||||
{
|
||||
Console.WriteLine("Enter invitee details.");
|
||||
string inviteeName = Invitation.GetValue("Invitee name: ");
|
||||
string inviteeEmail = Invitation.GetValue("Invitee email: ");
|
||||
Person invitee = new(inviteeName, inviteeEmail);
|
||||
invitees.Add(invitee);
|
||||
addInvitee = Invitation.GetResponse("Do you wish to add another invitee? (Y/N): ");
|
||||
}
|
||||
Console.Clear();
|
||||
foreach (Person invitee in invitees)
|
||||
{
|
||||
Console.WriteLine($"Dear {invitee.GetName()}, you have been invited for \"{activity.GetTitle()}\" on {activity.GetDate()}. Description: {activity.GetDescription()}\n\nKind regards,\n{organisor.GetName()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user