initial commit

This commit is contained in:
Edward Tirado Jr 2025-11-05 10:38:32 -06:00
commit 65c137cec1
32 changed files with 420 additions and 0 deletions

16
MadLib.sln Normal file
View file

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MadLib", "MadLib\MadLib.csproj", "{3F8F64F0-383A-427E-AB56-784D66A8FA76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F8F64F0-383A-427E-AB56-784D66A8FA76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F8F64F0-383A-427E-AB56-784D66A8FA76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F8F64F0-383A-427E-AB56-784D66A8FA76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F8F64F0-383A-427E-AB56-784D66A8FA76}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

10
MadLib/MadLib.csproj Normal file
View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

35
MadLib/Program.cs Normal file
View file

@ -0,0 +1,35 @@
namespace MadLib;
public class Program
{
public static void Main(string[] args)
{
var category = GetChoice();
var storyGenerator = new StoryGenerator(category);
storyGenerator.Generate();
}
private static StoryGenerator.Categories GetChoice()
{
while (true)
{
Console.WriteLine("Choose a category:");
StoryGenerator.DisplayCategories();
var choice = Console.ReadLine();
if (string.IsNullOrWhiteSpace(choice))
{
Console.WriteLine("Invalid input.");
continue;
}
var selectedCategory = int.Parse(choice.Trim()) - 1;
if (Enum.IsDefined(typeof(StoryGenerator.Categories), selectedCategory))
return (StoryGenerator.Categories)selectedCategory;
Console.WriteLine("Please enter a valid category.");
}
}
}

58
MadLib/StoryGenerator.cs Normal file
View file

@ -0,0 +1,58 @@
namespace MadLib;
public class StoryGenerator(StoryGenerator.Categories category)
{
public enum Categories
{
Adventure,
Science,
Fantasy,
Horror,
Mystery
}
private StoryTemplate _template;
public static void DisplayCategories()
{
foreach (var category in Enum.GetValues<Categories>()) Console.WriteLine($"{(int)category + 1}) {category}");
Console.WriteLine("\n");
}
public void Generate()
{
var storyWords = GetWords();
var story = _template.Text;
foreach (var placeholder in _template.Placeholders)
story = story.Replace($"[{placeholder}]", storyWords[placeholder]);
DisplayStory(story);
}
private Dictionary<string, string> GetWords()
{
if (!StoryTemplates.Templates.TryGetValue(category, out var template))
throw new Exception("Could not find Story Template.");
_template = template;
var words = new Dictionary<string, string>();
foreach (var placeholder in template.Placeholders)
{
Console.WriteLine($"Enter a {placeholder}: ");
var input = Console.ReadLine() ?? string.Empty;
words.Add(placeholder, input);
}
return words;
}
private void DisplayStory(string story)
{
Console.WriteLine("====================================================\n");
Console.WriteLine(story);
Console.WriteLine("\n====================================================");
}
}

33
MadLib/StoryTemplate.cs Normal file
View file

@ -0,0 +1,33 @@
namespace MadLib;
public record StoryTemplate(string Text, List<string> Placeholders);
internal static class StoryTemplates
{
public static readonly Dictionary<StoryGenerator.Categories, StoryTemplate> Templates = new()
{
[StoryGenerator.Categories.Adventure] = new StoryTemplate(
"'That [noun1] belongs in a museum!', said Dr. [last_name]. You can't just keep it in your own [noun2] all day! ",
["noun1", "last_name", "noun2"]),
[StoryGenerator.Categories.Mystery] =
new StoryTemplate("You're probably wondering why I've gathered you in this [noun]. " +
"After lots of time [verb]ing the witnesses and suspects, we have solved the crime. " +
"The killer was Mr. [last_name], in the [room], with a [noun]!",
["noun", "verb", "last_name", "room", "noun"]),
[StoryGenerator.Categories.Science] =
new StoryTemplate(
"The [animal] is the most ferocious animal on Earth. It can run at a speed of [number] miles per hour and " +
"uses its sharp [body_part] to hunt its prey. Its diet consists mostly of [noun1], [noun2], and [noun3].",
["animal", "number", "body_part", "noun1", "noun2", "noun3"]),
[StoryGenerator.Categories.Fantasy] =
new StoryTemplate(
"We're going on an adventure, [first_name1]! It's time to climb Mount [noun]. We'll need your strong [body_part] " +
"to retrieve the [noun] from the evil Dragon, [first_name2] the [occupation].",
["noun", "verb", "last_name", "room", "noun"]),
[StoryGenerator.Categories.Horror] =
new StoryTemplate(
"What?! No, of course I'm not a [monster], Mrs. [last_name]. Why, would a [monster] have a [body_part] like this?! " +
"Could a [monster] [verb] like this?! I have perfectly normal [color1] skin and [color2] hair, just like a normal human!",
["monster", "last_name", "body_part"])
};
}

BIN
MadLib/bin/Debug/net9.0/MadLib Executable file

Binary file not shown.

View file

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"MadLib/1.0.0": {
"runtime": {
"MadLib.dll": {}
}
}
}
},
"libraries": {
"MadLib/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View file

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View file

@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MadLib")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("MadLib")]
[assembly: System.Reflection.AssemblyTitleAttribute("MadLib")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View file

@ -0,0 +1 @@
ad766b57e38c197261c6ab34f76c9220e6b1722e3906bf018609983f7da22fc2

View file

@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = MadLib
build_property.ProjectDir = /home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View file

@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View file

@ -0,0 +1 @@
1fb7c2023d86e085dccce0602accad7542e5d0809c7dbacfc52176033cf7021a

View file

@ -0,0 +1,14 @@
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/bin/Debug/net9.0/MadLib
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/bin/Debug/net9.0/MadLib.deps.json
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/bin/Debug/net9.0/MadLib.runtimeconfig.json
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/bin/Debug/net9.0/MadLib.dll
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/bin/Debug/net9.0/MadLib.pdb
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.GeneratedMSBuildEditorConfig.editorconfig
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.AssemblyInfoInputs.cache
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.AssemblyInfo.cs
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.csproj.CoreCompileInputs.cache
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.dll
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/refint/MadLib.dll
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.pdb
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/MadLib.genruntimeconfig.cache
/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/Debug/net9.0/ref/MadLib.dll

Binary file not shown.

View file

@ -0,0 +1 @@
6a6151e4db060c8799136f4de68333ca96d29d3ef7fedf54a2108e005f0739e8

Binary file not shown.

BIN
MadLib/obj/Debug/net9.0/apphost Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,67 @@
{
"format": 1,
"restore": {
"/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj": {}
},
"projects": {
"/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj",
"projectName": "MadLib",
"projectPath": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj",
"packagesPath": "/home/tiradoe/.nuget/packages/",
"outputPath": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/tiradoe/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/home/tiradoe/.dotnet/sdk/9.0.305/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/tiradoe/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/tiradoe/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/tiradoe/.nuget/packages/" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View file

@ -0,0 +1,72 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/tiradoe/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj",
"projectName": "MadLib",
"projectPath": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj",
"packagesPath": "/home/tiradoe/.nuget/packages/",
"outputPath": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/tiradoe/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/home/tiradoe/.dotnet/sdk/9.0.305/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View file

@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "5CXaSy6Fg0U=",
"success": true,
"projectFilePath": "/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj",
"expectedPackageFiles": [],
"logs": []
}

View file

@ -0,0 +1 @@
"restore":{"projectUniqueName":"/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj","projectName":"MadLib","projectPath":"/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/MadLib.csproj","outputPath":"/home/tiradoe/Projects/practice/csharp/MadLib/MadLib/MadLib/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net9.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net9.0":{"targetAlias":"net9.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"},"SdkAnalysisLevel":"9.0.300"}"frameworks":{"net9.0":{"targetAlias":"net9.0","imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/home/tiradoe/.dotnet/sdk/9.0.305/PortableRuntimeIdentifierGraph.json"}}

View file

@ -0,0 +1 @@
17600467351755310

View file

@ -0,0 +1 @@
17600467351755310