mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-02-05 11:26:37 -08:00
Merge branch 'coding-horror:main' into main
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -30,5 +30,4 @@ out/
|
||||
Pipfile
|
||||
|
||||
.DS_Store
|
||||
/.vs/basic-computer-games/v16
|
||||
/.vs
|
||||
.vs/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using static System.IO.Path;
|
||||
|
||||
namespace DotnetUtils;
|
||||
|
||||
@@ -9,6 +10,11 @@ public static class Extensions {
|
||||
src.Select(x => selector(x.Item1, x.Item2, x.Item3));
|
||||
public static IEnumerable<(T1, T2, int)> WithIndex<T1, T2>(this IEnumerable<(T1, T2)> src) => src.Select((x, index) => (x.Item1, x.Item2, index));
|
||||
|
||||
public static bool None<T>(this IEnumerable<T> src, Func<T, bool>? predicate = null) =>
|
||||
predicate is null ?
|
||||
!src.Any() :
|
||||
!src.Any(predicate);
|
||||
|
||||
public static bool IsNullOrWhitespace([NotNullWhen(false)] this string? s) => string.IsNullOrWhiteSpace(s);
|
||||
|
||||
[return: NotNullIfNotNull("path")]
|
||||
@@ -18,10 +24,7 @@ public static class Extensions {
|
||||
rootPath.IsNullOrWhitespace()
|
||||
) { return path; }
|
||||
|
||||
var path1 = path.TrimEnd('\\');
|
||||
rootPath = rootPath.TrimEnd('\\');
|
||||
if (!path1.StartsWith(rootPath, StringComparison.InvariantCultureIgnoreCase)) { return path; }
|
||||
|
||||
return path1[(rootPath.Length + 1)..]; // ignore the initial /
|
||||
path = path.TrimEnd('\\'); // remove trailing backslash, if present
|
||||
return GetRelativePath(rootPath, path.TrimEnd('\\'));
|
||||
}
|
||||
}
|
||||
|
||||
35
00_Utilities/DotnetUtils/DotnetUtils/Functions.cs
Normal file
35
00_Utilities/DotnetUtils/DotnetUtils/Functions.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Xml.Linq;
|
||||
using static System.Console;
|
||||
|
||||
namespace DotnetUtils;
|
||||
|
||||
public static class Functions {
|
||||
public static string? getValue(string path, params string[] names) {
|
||||
if (names.Length == 0) { throw new InvalidOperationException(); }
|
||||
var parent = XDocument.Load(path).Element("Project")?.Element("PropertyGroup");
|
||||
return getValue(parent, names);
|
||||
}
|
||||
|
||||
public static string? getValue(XElement? parent, params string[] names) {
|
||||
if (names.Length == 0) { throw new InvalidOperationException(); }
|
||||
XElement? elem = null;
|
||||
foreach (var name in names) {
|
||||
elem = parent?.Element(name);
|
||||
if (elem != null) { break; }
|
||||
}
|
||||
return elem?.Value;
|
||||
}
|
||||
|
||||
public static int getChoice(int maxValue) => getChoice(0, maxValue);
|
||||
|
||||
public static int getChoice(int minValue, int maxValue) {
|
||||
int result;
|
||||
do {
|
||||
Write("? ");
|
||||
} while (!int.TryParse(ReadLine(), out result) || result < minValue || result > maxValue);
|
||||
//WriteLine();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
88
00_Utilities/DotnetUtils/DotnetUtils/Methods.cs
Normal file
88
00_Utilities/DotnetUtils/DotnetUtils/Methods.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DotnetUtils;
|
||||
|
||||
public static class Methods {
|
||||
public static ProcessResult RunProcess(string filename, string arguments) {
|
||||
var process = new Process() {
|
||||
StartInfo = {
|
||||
FileName = filename,
|
||||
Arguments = arguments,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
},
|
||||
EnableRaisingEvents = true
|
||||
};
|
||||
return RunProcess(process);
|
||||
}
|
||||
|
||||
public static ProcessResult RunProcess(Process process, string input = "") {
|
||||
var (output, error) = ("", "");
|
||||
var (redirectOut, redirectErr) = (
|
||||
process.StartInfo.RedirectStandardOutput,
|
||||
process.StartInfo.RedirectStandardError
|
||||
);
|
||||
if (redirectOut) {
|
||||
process.OutputDataReceived += (s, ea) => output += ea.Data + "\n";
|
||||
}
|
||||
if (redirectErr) {
|
||||
process.ErrorDataReceived += (s, ea) => error += ea.Data + "\n";
|
||||
}
|
||||
|
||||
if (!process.Start()) {
|
||||
throw new InvalidOperationException();
|
||||
};
|
||||
|
||||
if (redirectOut) { process.BeginOutputReadLine(); }
|
||||
if (redirectErr) { process.BeginErrorReadLine(); }
|
||||
if (!string.IsNullOrEmpty(input)) {
|
||||
process.StandardInput.WriteLine(input);
|
||||
process.StandardInput.Close();
|
||||
}
|
||||
process.WaitForExit();
|
||||
return new ProcessResult(process.ExitCode, output, error);
|
||||
}
|
||||
|
||||
public static Task<ProcessResult> RunProcessAsync(Process process, string input = "") {
|
||||
var tcs = new TaskCompletionSource<ProcessResult>();
|
||||
var (output, error) = ("", "");
|
||||
var (redirectOut, redirectErr) = (
|
||||
process.StartInfo.RedirectStandardOutput,
|
||||
process.StartInfo.RedirectStandardError
|
||||
);
|
||||
|
||||
process.Exited += (s, e) => tcs.SetResult(new ProcessResult(process.ExitCode, output, error));
|
||||
|
||||
if (redirectOut) {
|
||||
process.OutputDataReceived += (s, ea) => output += ea.Data + "\n";
|
||||
}
|
||||
if (redirectErr) {
|
||||
process.ErrorDataReceived += (s, ea) => error += ea.Data + "\n";
|
||||
}
|
||||
|
||||
if (!process.Start()) {
|
||||
// what happens to the Exited event if process doesn't start successfully?
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (redirectOut) { process.BeginOutputReadLine(); }
|
||||
if (redirectErr) { process.BeginErrorReadLine(); }
|
||||
if (!string.IsNullOrEmpty(input)) {
|
||||
process.StandardInput.WriteLine(input);
|
||||
process.StandardInput.Close();
|
||||
}
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record ProcessResult(int ExitCode, string StdOut, string StdErr) {
|
||||
public override string? ToString() =>
|
||||
StdOut +
|
||||
(StdOut is not (null or "") && ExitCode > 0 ? "\n" : "") +
|
||||
(ExitCode != 0 ?
|
||||
$"{ExitCode}\n{StdErr}" :
|
||||
"");
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Reflection;
|
||||
using static System.IO.Directory;
|
||||
using static System.IO.Directory;
|
||||
using static System.IO.Path;
|
||||
using static DotnetUtils.Globals;
|
||||
|
||||
namespace DotnetUtils;
|
||||
|
||||
public record PortInfo(
|
||||
string FullPath, string FolderName, int Index, string GameName,
|
||||
string GamePath, string FolderName, int Index, string GameName,
|
||||
string LangPath, string Lang, string Ext, string ProjExt,
|
||||
string[] CodeFiles, string[] Slns, string[] Projs
|
||||
) {
|
||||
@@ -17,31 +16,40 @@ public record PortInfo(
|
||||
MatchCasing = MatchCasing.CaseInsensitive
|
||||
};
|
||||
|
||||
public static PortInfo? Create(string fullPath, string langKeyword) {
|
||||
var folderName = GetFileName(fullPath);
|
||||
// .NET namespaces cannot have a digit as the first character
|
||||
// For games whose name starts with a digit, we map the name to a specific string
|
||||
private static readonly Dictionary<string, string> specialGameNames = new() {
|
||||
{ "3-D_Plot", "Plot" },
|
||||
{ "3-D_Tic-Tac-Toe", "ThreeDTicTacToe" },
|
||||
{ "23_Matches", "TwentyThreeMatches"}
|
||||
};
|
||||
|
||||
public static PortInfo? Create(string gamePath, string langKeyword) {
|
||||
var folderName = GetFileName(gamePath);
|
||||
var parts = folderName.Split('_', 2);
|
||||
|
||||
var index =
|
||||
parts.Length > 0 && int.TryParse(parts[0], out var n) ?
|
||||
if (parts.Length <= 1) { return null; }
|
||||
|
||||
var (index, gameName) = (
|
||||
int.TryParse(parts[0], out var n) && n > 0 ? // ignore utilities folder
|
||||
n :
|
||||
(int?)null;
|
||||
(int?)null,
|
||||
specialGameNames.TryGetValue(parts[1], out var specialName) ?
|
||||
specialName :
|
||||
parts[1].Replace("_", "").Replace("-", "")
|
||||
);
|
||||
|
||||
var gameName =
|
||||
parts.Length > 1 ?
|
||||
parts[1].Replace("_", "") :
|
||||
null;
|
||||
|
||||
if (index is 0 or null || gameName is null) { return null; }
|
||||
if (index is null || gameName is null) { return null; }
|
||||
|
||||
var (ext, projExt) = LangData[langKeyword];
|
||||
var langPath = Combine(fullPath, langKeyword);
|
||||
var langPath = Combine(gamePath, langKeyword);
|
||||
var codeFiles =
|
||||
GetFiles(langPath, $"*.{ext}", enumerationOptions)
|
||||
.Where(x => !x.Contains("\\bin\\") && !x.Contains("\\obj\\"))
|
||||
.ToArray();
|
||||
|
||||
return new PortInfo(
|
||||
fullPath, folderName, index.Value, gameName,
|
||||
gamePath, folderName, index.Value, gameName,
|
||||
langPath, langKeyword, ext, projExt,
|
||||
codeFiles,
|
||||
GetFiles(langPath, "*.sln", enumerationOptions),
|
||||
|
||||
@@ -12,8 +12,8 @@ public static class PortInfos {
|
||||
Root = Root[..Root.IndexOf(@"\00_Utilities")];
|
||||
|
||||
Get = GetDirectories(Root)
|
||||
.SelectMany(fullPath => LangData.Keys.Select(keyword => (fullPath, keyword)))
|
||||
.SelectT((fullPath, keyword) => PortInfo.Create(fullPath, keyword))
|
||||
.SelectMany(gamePath => LangData.Keys.Select(keyword => (gamePath, keyword)))
|
||||
.SelectT((gamePath, keyword) => PortInfo.Create(gamePath, keyword))
|
||||
.Where(x => x is not null)
|
||||
.ToArray()!;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using DotnetUtils;
|
||||
using System.Xml.Linq;
|
||||
using DotnetUtils;
|
||||
using static System.Console;
|
||||
using static System.IO.Path;
|
||||
using static DotnetUtils.Methods;
|
||||
using static DotnetUtils.Functions;
|
||||
|
||||
var infos = PortInfos.Get;
|
||||
|
||||
@@ -11,7 +14,14 @@ var actions = new (Action action, string description)[] {
|
||||
(multipleSlns, "Output multiple sln files"),
|
||||
(missingProj, "Output missing project file"),
|
||||
(unexpectedProjName, "Output misnamed project files"),
|
||||
(multipleProjs, "Output multiple project files")
|
||||
(multipleProjs, "Output multiple project files"),
|
||||
(checkProjects, "Check .csproj/.vbproj files for target framework, nullability etc."),
|
||||
(checkExecutableProject, "Check that there is at least one executable project per port"),
|
||||
(noCodeFiles, "Output ports without any code files"),
|
||||
(printPortInfo, "Print info about a single port"),
|
||||
|
||||
(generateMissingSlns, "Generate solution files when missing"),
|
||||
(generateMissingProjs, "Generate project files when missing")
|
||||
};
|
||||
|
||||
foreach (var (_, description, index) in actions.WithIndex()) {
|
||||
@@ -22,15 +32,6 @@ WriteLine();
|
||||
|
||||
actions[getChoice(actions.Length - 1)].action();
|
||||
|
||||
int getChoice(int maxValue) {
|
||||
int result;
|
||||
do {
|
||||
Write("? ");
|
||||
} while (!int.TryParse(ReadLine(), out result) || result < 0 || result > maxValue);
|
||||
WriteLine();
|
||||
return result;
|
||||
}
|
||||
|
||||
void printSlns(PortInfo pi) {
|
||||
switch (pi.Slns.Length) {
|
||||
case 0:
|
||||
@@ -65,7 +66,6 @@ void printProjs(PortInfo pi) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
WriteLine();
|
||||
}
|
||||
|
||||
void printInfos() {
|
||||
@@ -88,7 +88,7 @@ void printInfos() {
|
||||
}
|
||||
|
||||
void missingSln() {
|
||||
var data = infos.Where(x => !x.Slns.Any()).ToArray();
|
||||
var data = infos.Where(x => x.Slns.None()).ToArray();
|
||||
foreach (var item in data) {
|
||||
WriteLine(item.LangPath);
|
||||
}
|
||||
@@ -99,10 +99,10 @@ void missingSln() {
|
||||
void unexpectedSlnName() {
|
||||
var counter = 0;
|
||||
foreach (var item in infos) {
|
||||
if (!item.Slns.Any()) { continue; }
|
||||
if (item.Slns.None()) { continue; }
|
||||
|
||||
var expectedSlnName = $"{item.GameName}.sln";
|
||||
if (item.Slns.Contains(Combine(item.LangPath, expectedSlnName))) { continue; }
|
||||
if (item.Slns.Contains(Combine(item.LangPath, expectedSlnName), StringComparer.InvariantCultureIgnoreCase)) { continue; }
|
||||
|
||||
counter += 1;
|
||||
WriteLine(item.LangPath);
|
||||
@@ -126,7 +126,7 @@ void multipleSlns() {
|
||||
}
|
||||
|
||||
void missingProj() {
|
||||
var data = infos.Where(x => !x.Projs.Any()).ToArray();
|
||||
var data = infos.Where(x => x.Projs.None()).ToArray();
|
||||
foreach (var item in data) {
|
||||
WriteLine(item.LangPath);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ void missingProj() {
|
||||
void unexpectedProjName() {
|
||||
var counter = 0;
|
||||
foreach (var item in infos) {
|
||||
if (!item.Projs.Any()) { continue; }
|
||||
if (item.Projs.None()) { continue; }
|
||||
|
||||
var expectedProjName = $"{item.GameName}.{item.ProjExt}";
|
||||
if (item.Projs.Contains(Combine(item.LangPath, expectedProjName))) { continue; }
|
||||
@@ -159,8 +159,205 @@ void multipleProjs() {
|
||||
WriteLine(item.LangPath);
|
||||
WriteLine();
|
||||
printProjs(item);
|
||||
|
||||
}
|
||||
WriteLine();
|
||||
WriteLine($"Count: {data.Length}");
|
||||
}
|
||||
|
||||
void generateMissingSlns() {
|
||||
foreach (var item in infos.Where(x => x.Slns.None())) {
|
||||
var result = RunProcess("dotnet", $"new sln -n {item.GameName} -o {item.LangPath}");
|
||||
WriteLine(result);
|
||||
|
||||
var slnFullPath = Combine(item.LangPath, $"{item.GameName}.sln");
|
||||
foreach (var proj in item.Projs) {
|
||||
result = RunProcess("dotnet", $"sln {slnFullPath} add {proj}");
|
||||
WriteLine(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void generateMissingProjs() {
|
||||
foreach (var item in infos.Where(x => x.Projs.None())) {
|
||||
// We can't use the dotnet command to create a new project using the built-in console template, because part of that template
|
||||
// is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
|
||||
// if there's already such a file, it might try to overwrite it.
|
||||
|
||||
var projText = item.Lang switch {
|
||||
"csharp" => @"<Project Sdk=""Microsoft.NET.Sdk"">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
",
|
||||
"vbnet" => @$"<Project Sdk=""Microsoft.NET.Sdk"">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>{item.GameName}</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
",
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
var projFullPath = Combine(item.LangPath, $"{item.GameName}.{item.ProjExt}");
|
||||
File.WriteAllText(projFullPath, projText);
|
||||
|
||||
if (item.Slns.Length == 1) {
|
||||
var result = RunProcess("dotnet", $"sln {item.Slns[0]} add {projFullPath}");
|
||||
WriteLine(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkProjects() {
|
||||
foreach (var info in infos) {
|
||||
WriteLine(info.LangPath);
|
||||
printProjectWarnings(info);
|
||||
}
|
||||
}
|
||||
|
||||
void printProjectWarnings(PortInfo info) {
|
||||
foreach (var proj in info.Projs) {
|
||||
var warnings = new List<string>();
|
||||
var parent = XDocument.Load(proj).Element("Project")?.Element("PropertyGroup");
|
||||
|
||||
var (
|
||||
framework,
|
||||
nullable,
|
||||
implicitUsing,
|
||||
rootNamespace,
|
||||
langVersion,
|
||||
optionStrict
|
||||
) = (
|
||||
getValue(parent, "TargetFramework", "TargetFrameworks"),
|
||||
getValue(parent, "Nullable"),
|
||||
getValue(parent, "ImplicitUsings"),
|
||||
getValue(parent, "RootNamespace"),
|
||||
getValue(parent, "LangVersion"),
|
||||
getValue(parent, "OptionStrict")
|
||||
);
|
||||
|
||||
if (framework != "net6.0") {
|
||||
warnings.Add($"Target: {framework}");
|
||||
}
|
||||
|
||||
if (info.Lang == "csharp") {
|
||||
if (nullable != "enable") {
|
||||
warnings.Add($"Nullable: {nullable}");
|
||||
}
|
||||
if (implicitUsing != "enable") {
|
||||
warnings.Add($"ImplicitUsings: {implicitUsing}");
|
||||
}
|
||||
if (rootNamespace != null && rootNamespace != info.GameName) {
|
||||
warnings.Add($"RootNamespace: {rootNamespace}");
|
||||
}
|
||||
if (langVersion != "10") {
|
||||
warnings.Add($"LangVersion: {langVersion}");
|
||||
}
|
||||
}
|
||||
|
||||
if (info.Lang == "vbnet") {
|
||||
if (rootNamespace != info.GameName) {
|
||||
warnings.Add($"RootNamespace: {rootNamespace}");
|
||||
}
|
||||
if (langVersion != "16.9") {
|
||||
warnings.Add($"LangVersion: {langVersion}");
|
||||
}
|
||||
if (optionStrict != "On") {
|
||||
warnings.Add($"OptionStrict: {optionStrict}");
|
||||
}
|
||||
}
|
||||
|
||||
if (warnings.Any()) {
|
||||
WriteLine(proj.RelativePath(info.LangPath));
|
||||
WriteLine(string.Join("\n", warnings));
|
||||
WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkExecutableProject() {
|
||||
foreach (var item in infos) {
|
||||
if (item.Projs.All(proj => getValue(proj, "OutputType") != "Exe")) {
|
||||
WriteLine($"{item.LangPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void noCodeFiles() {
|
||||
var qry = infos
|
||||
.Where(x => x.CodeFiles.None())
|
||||
.OrderBy(x => x.Lang);
|
||||
foreach (var item in qry) {
|
||||
WriteLine(item.LangPath);
|
||||
}
|
||||
}
|
||||
|
||||
void tryBuild() {
|
||||
// if has code files, try to build
|
||||
}
|
||||
|
||||
void printPortInfo() {
|
||||
// prompt for port number
|
||||
Write("Enter number from 1 to 96 ");
|
||||
var index = getChoice(1, 96);
|
||||
|
||||
Write("Enter 0 for C#, 1 for VB ");
|
||||
var lang = getChoice(1) switch {
|
||||
0 => "csharp",
|
||||
1 => "vbnet",
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
|
||||
WriteLine();
|
||||
|
||||
var info = infos.Single(x => x.Index == index && x.Lang == lang);
|
||||
|
||||
WriteLine(info.LangPath);
|
||||
WriteLine(new string('-', 50));
|
||||
|
||||
// print solutions
|
||||
printSlns(info);
|
||||
|
||||
// mismatched solution name/location? (expected x)
|
||||
var expectedSlnName = Combine(info.LangPath, $"{info.GameName}.sln");
|
||||
if (!info.Slns.Contains(expectedSlnName)) {
|
||||
WriteLine($"Expected name/path: {expectedSlnName.RelativePath(info.LangPath)}");
|
||||
}
|
||||
|
||||
// has executable project?
|
||||
if (info.Projs.All(proj => getValue(proj, "OutputType") != "Exe")) {
|
||||
WriteLine("No executable project");
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
|
||||
// print projects
|
||||
printProjs(info);
|
||||
|
||||
// mimsatched project name/location? (expected x)
|
||||
var expectedProjName = Combine(info.LangPath, $"{info.GameName}.{info.ProjExt}");
|
||||
if (info.Projs.Length < 2 && !info.Projs.Contains(expectedProjName)) {
|
||||
WriteLine($"Expected name/path: {expectedProjName.RelativePath(info.LangPath)}");
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
|
||||
// verify project properties
|
||||
printProjectWarnings(info);
|
||||
|
||||
WriteLine("Code files:");
|
||||
|
||||
// list code files
|
||||
foreach (var codeFile in info.CodeFiles) {
|
||||
WriteLine(codeFile.RelativePath(info.LangPath));
|
||||
}
|
||||
|
||||
// try build
|
||||
}
|
||||
|
||||
55
00_Utilities/yatol.pl
Executable file
55
00_Utilities/yatol.pl
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/perl
|
||||
#YATOL: Yet Another TOdo List
|
||||
use strict;
|
||||
|
||||
#REM: Get list of basic files ordered by number of lines.
|
||||
#REM: This way you can do the easier ones first.
|
||||
my @Ret=`find .. -iname '*.bas' -exec wc -l \{\} \\; | sort -h`;
|
||||
|
||||
|
||||
my @Langs= qw(PL JS VB PAS RB C# JAVA PY);
|
||||
my @Dirs= qw(perl javascript vbnet pascal ruby csharp java python);
|
||||
my %Sum;
|
||||
|
||||
print " "x 25 ."BAS\t";
|
||||
foreach my $Dir (@Langs) {
|
||||
print "$Dir\t";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
my $Count;
|
||||
foreach my $Lin (@Ret) {
|
||||
$Count++;
|
||||
chomp $Lin;
|
||||
my ($Num, $File)= split (" ", $Lin);
|
||||
my @Parts= split(/\//, $File);
|
||||
my $Base= $Parts[1];
|
||||
|
||||
my $Tab= 25-length($Base);
|
||||
print "$Base".(" "x$Tab)."$Num\t";
|
||||
|
||||
foreach my $Dir (@Dirs) {
|
||||
my $Path= "../$Base/$Dir/";
|
||||
my $Ret= `ls $Path | wc -l`;
|
||||
if ($Ret>1) { print "YES"; $Sum{$Dir}++; }
|
||||
else { print " ";}
|
||||
print "\t";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
}
|
||||
|
||||
print "\t\tFILES:\t\t";
|
||||
foreach my $Dir (@Dirs) {
|
||||
print "$Sum{$Dir}\t";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
|
||||
print "\t\tADVANCE:\t";
|
||||
foreach my $Dir (@Dirs) {
|
||||
my $Per= int($Sum{$Dir}/$Count*100)."%";
|
||||
print "$Per\t";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
74
01_Acey_Ducey/kotlin/aceyducey.kt
Normal file
74
01_Acey_Ducey/kotlin/aceyducey.kt
Normal file
@@ -0,0 +1,74 @@
|
||||
import java.util.Random
|
||||
|
||||
fun printCard(a: Int) {
|
||||
if (a < 11) println(a)
|
||||
if (a == 11) println("JACK")
|
||||
if (a == 12) println("QUEEN")
|
||||
if (a == 13) println("KING")
|
||||
if (a == 14) println("ACE")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
println("ACEY DUCEY CARD GAME")
|
||||
println("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
println()
|
||||
println()
|
||||
println("ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER ")
|
||||
println("THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP")
|
||||
println("YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING")
|
||||
println("ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE")
|
||||
println("A VALUE BETWEEN THE FIRST TWO.")
|
||||
println("IF YOU DO NOT WANT TO BET, INPUT A 0")
|
||||
var random = Random()
|
||||
do {
|
||||
var q = 100
|
||||
var a : Int
|
||||
var b : Int
|
||||
var m : Int
|
||||
println("YOU NOW HAVE " + q + " DOLLARS.")
|
||||
println()
|
||||
do {
|
||||
do {
|
||||
do {
|
||||
println("HERE ARE YOUR NEXT TWO CARDS: ")
|
||||
do {
|
||||
a = random.nextInt(12) + 2
|
||||
b = random.nextInt(12) + 2
|
||||
} while (a >= b);
|
||||
printCard(a)
|
||||
printCard(b)
|
||||
println()
|
||||
println()
|
||||
print("WHAT IS YOUR BET")
|
||||
m = readLine()!!.toInt()
|
||||
if (m == 0) {
|
||||
println("CHICKEN!!")
|
||||
println()
|
||||
}
|
||||
} while (m == 0);
|
||||
if (m > q) {
|
||||
println("SORRY, MY FRIEND, BUT YOU BET TOO MUCH.")
|
||||
println("YOU HAVE ONLY " + q + " DOLLARS TO BET.")
|
||||
}
|
||||
} while (m > q);
|
||||
var c = random.nextInt(12) + 2
|
||||
printCard(c)
|
||||
println()
|
||||
if (c > a && c < b) {
|
||||
println("YOU WIN!!!")
|
||||
q += m
|
||||
}
|
||||
else {
|
||||
println("SORRY, YOU LOSE")
|
||||
if (m < q) q -= m
|
||||
}
|
||||
} while (m < q);
|
||||
println()
|
||||
println()
|
||||
println("SORRY, FRIEND, BUT YOU BLEW YOUR WAD.")
|
||||
println()
|
||||
println()
|
||||
println("TRY AGAIN (YES OR NO)")
|
||||
} while (readLine() == "YES");
|
||||
println("O.K., HOPE YOU HAD FUN!")
|
||||
}
|
||||
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AceyDucy", "AceyDucy\AceyDucy.vbproj", "{37496710-B458-4502-ADCB-4C57203866F9}"
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "AceyDucey", "AceyDucey.vbproj", "{54C05475-238D-4A82-A67B-B6C1BF2CA337}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -11,10 +11,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{37496710-B458-4502-ADCB-4C57203866F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{37496710-B458-4502-ADCB-4C57203866F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{37496710-B458-4502-ADCB-4C57203866F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{37496710-B458-4502-ADCB-4C57203866F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{54C05475-238D-4A82-A67B-B6C1BF2CA337}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{54C05475-238D-4A82-A67B-B6C1BF2CA337}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{54C05475-238D-4A82-A67B-B6C1BF2CA337}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{54C05475-238D-4A82-A67B-B6C1BF2CA337}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
242
01_Acey_Ducey/vbnet/AceyDucey.vb
Normal file
242
01_Acey_Ducey/vbnet/AceyDucey.vb
Normal file
@@ -0,0 +1,242 @@
|
||||
Public Class AceyDucey
|
||||
''' <summary>
|
||||
''' Create a single instance of the Random class to be used
|
||||
''' throughout the program.
|
||||
''' </summary>
|
||||
Private ReadOnly Property Rnd As New Random()
|
||||
|
||||
''' <summary>
|
||||
''' Define a varaible to store the the player balance. <br/>
|
||||
''' Defaults to 0
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' Since <see cref="Integer"/> is a value type, and no value
|
||||
''' has been explicitly set, the default value of the type is used.
|
||||
''' </remarks>
|
||||
Private _balance As Integer
|
||||
|
||||
Public Sub New()
|
||||
DisplayIntroduction()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Play multiple games of Acey Ducey until the player chooses to quit.
|
||||
''' </summary>
|
||||
Public Sub Play()
|
||||
Do
|
||||
PlayGame()
|
||||
Loop While TryAgain() 'Loop (play again) based on the Boolean value returned by TryAgain
|
||||
|
||||
Console.WriteLine("O.K., HOPE YOU HAD FUN!")
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Play a game of Acey Ducey, which ends when the player balance reaches 0
|
||||
''' </summary>
|
||||
Private Sub PlayGame()
|
||||
_balance = 100 'At the start of the game, set the player balance to 100
|
||||
|
||||
Console.WriteLine()
|
||||
Console.WriteLine($"YOU NOW HAVE {_balance} DOLLARS.")
|
||||
|
||||
Do
|
||||
PlayTurn()
|
||||
Loop While _balance > 0 'Continue playing while the user has a balance
|
||||
|
||||
Console.WriteLine()
|
||||
Console.WriteLine("SORRY, FRIEND, BUT YOU BLEW YOUR WAD.")
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Play one turn of Acey Ducey
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' A turn consists of displaying to cards, making a wager
|
||||
''' and determining the result (win/lose)
|
||||
''' </remarks>
|
||||
Private Sub PlayTurn()
|
||||
Console.WriteLine()
|
||||
Console.WriteLine("HERE ARE YOUR NEXT TWO CARDS: ")
|
||||
|
||||
Dim cards = GetOrderedCards()
|
||||
|
||||
For Each card In cards
|
||||
DisplayCard(card)
|
||||
Next
|
||||
|
||||
Dim wager As Integer = GetWager()
|
||||
Dim finalCard As Integer = GetCard()
|
||||
|
||||
If wager = 0 Then
|
||||
Console.WriteLine("CHICKEN!!")
|
||||
Return
|
||||
End If
|
||||
|
||||
DisplayCard(finalCard)
|
||||
|
||||
Console.WriteLine()
|
||||
|
||||
'''Check if the value of the final card is between the first and second cards.
|
||||
'''
|
||||
'''The use of AndAlso is used to short-circuit the evaluation of the IF condition.
|
||||
'''Short-circuiting means that both sides of the condition do not need to be
|
||||
'''evaluated. In this case, if the left criteria returns FALSE, the right criteria
|
||||
'''is ignored and the evaluation result is returned as FALSE.
|
||||
'''
|
||||
'''This works because AndAlso requires both condition to return TRUE in order to be
|
||||
'''evaluated as TRUE. If the first condition is FALSE we already know the evaluation result.
|
||||
If finalCard >= cards.First() AndAlso finalCard <= cards.Last() Then
|
||||
Console.WriteLine("YOU WIN!!!")
|
||||
_balance += wager 'Condensed version of _balance = _balance + wager
|
||||
Else
|
||||
Console.WriteLine("SORRY, YOU LOSE.")
|
||||
_balance -= wager 'Condensed version of _balance = _balance - wager
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Get two cards in ascending order
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' The original version generates two cards (A and B)
|
||||
''' If A is greater than or equal to B, both cards are regenerated.
|
||||
''' <br/><br/>
|
||||
''' This version generates the two cards, but only regenerates A
|
||||
''' if A is equal to B. The cards are then returned is ascending order,
|
||||
''' ensuring that A is less than B (maintaining the original end result)
|
||||
''' </remarks>
|
||||
Private Function GetOrderedCards() As Integer()
|
||||
'''When declaring fixed size arrays in VB.NET you declare the MAX INDEX of the array
|
||||
'''and NOT the SIZE (number of elements) of the array.
|
||||
'''As such, card(1) gives you and array with index 0 and index 1, which means
|
||||
'''the array stores two elements and not one
|
||||
Dim cards(1) As Integer
|
||||
|
||||
cards(0) = GetCard()
|
||||
cards(1) = GetCard()
|
||||
|
||||
'Perform this action as long as the first card is equal to the second card
|
||||
While cards(0) = cards(1)
|
||||
cards(0) = GetCard()
|
||||
End While
|
||||
|
||||
Array.Sort(cards) 'Sort the values in ascending order
|
||||
|
||||
Return cards
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Get a random number (card) ranked 2 to 14
|
||||
''' </summary>
|
||||
Private Function GetCard() As Integer
|
||||
Return Rnd.Next(2, 15)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Display the face value of the card
|
||||
''' </summary>
|
||||
Private Sub DisplayCard(card As Integer)
|
||||
Dim output As String
|
||||
|
||||
Select Case card
|
||||
Case 2 To 10
|
||||
output = card.ToString()
|
||||
Case 11
|
||||
output = "JACK"
|
||||
Case 12
|
||||
output = "QUEEN"
|
||||
Case 13
|
||||
output = "KING"
|
||||
Case 14
|
||||
output = "ACE"
|
||||
Case Else
|
||||
Throw New ArgumentOutOfRangeException(NameOf(card), "Value must be between 2 and 14")
|
||||
End Select
|
||||
|
||||
Console.WriteLine(output)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Prompt the user to make a bet
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' The function will not return until a valid bet is made. <br/>
|
||||
''' <see cref="Int32.TryParse(String, ByRef Integer)"/> is used to validate that the user input is a valid <see cref="Integer"/>
|
||||
''' </remarks>
|
||||
Private Function GetWager() As Integer
|
||||
Dim wager As Integer
|
||||
Do
|
||||
Console.WriteLine()
|
||||
Console.Write("WHAT IS YOUR BET? ")
|
||||
|
||||
Dim input As String = Console.ReadLine()
|
||||
|
||||
'''Determine if the user input is an Integer
|
||||
'''If it is an Integer, store the value in the variable wager
|
||||
If Not Integer.TryParse(input, wager) Then
|
||||
Console.WriteLine("SORRY, I DID'T QUITE GET THAT.")
|
||||
Continue Do 'restart the loop
|
||||
End If
|
||||
|
||||
'Prevent the user from betting more than their current balance
|
||||
If _balance < wager Then
|
||||
Console.WriteLine("SORRY, MY FRIEND, BUT YOU BET TOO MUCH.")
|
||||
Console.WriteLine($"YOU HAVE ONLY {_balance} DOLLARS TO BET.")
|
||||
Continue Do 'restart the loop
|
||||
End If
|
||||
|
||||
'Prevent the user from betting negative values
|
||||
If wager < 0 Then
|
||||
Console.WriteLine("FUNNY GUY! YOU CANNOT MAKE A NEGATIVE BET.")
|
||||
Continue Do 'restart the loop
|
||||
End If
|
||||
|
||||
Exit Do 'If we get to this line, exit the loop as all above validations passed
|
||||
Loop
|
||||
|
||||
Return wager
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Prompt the user to try again
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' This function will not return until a valid reponse is given
|
||||
''' </remarks>
|
||||
Private Function TryAgain() As Boolean
|
||||
Dim response As String
|
||||
Do
|
||||
Console.Write("TRY AGAIN (YES OR NO) ")
|
||||
|
||||
response = Console.ReadLine()
|
||||
|
||||
If response.Equals("YES", StringComparison.OrdinalIgnoreCase) Then Return True
|
||||
If response.Equals("NO", StringComparison.OrdinalIgnoreCase) Then Return False
|
||||
|
||||
Console.WriteLine("SORRY, I DID'T QUITE GET THAT.")
|
||||
Loop
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Display the opening title and instructions
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' Refer to
|
||||
''' <see href="https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/strings/interpolated-strings">
|
||||
''' Interpolated Strings
|
||||
''' </see> documentation for the use of $ and { } with strings
|
||||
''' </remarks>
|
||||
Private Sub DisplayIntroduction()
|
||||
Console.WriteLine($"{Space((Console.WindowWidth \ 2) - 10)}ACEY DUCEY CARD GAME")
|
||||
Console.WriteLine($"{Space((Console.WindowWidth \ 2) - 21)}CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER")
|
||||
Console.WriteLine("THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP")
|
||||
Console.WriteLine("YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING")
|
||||
Console.WriteLine("ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE")
|
||||
Console.WriteLine("A VALUE BETWEEN THE FIRST TWO.")
|
||||
Console.WriteLine("IF YOU DO NOT WANT TO BET, INPUT A 0")
|
||||
Console.WriteLine("")
|
||||
End Sub
|
||||
End Class
|
||||
10
01_Acey_Ducey/vbnet/AceyDucey.vbproj
Normal file
10
01_Acey_Ducey/vbnet/AceyDucey.vbproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>AceyDucey</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,178 +0,0 @@
|
||||
Imports System
|
||||
|
||||
''' <summary>
|
||||
''' This is a modern adapation of Acey Ducey from BASIC Computer Games.
|
||||
'''
|
||||
''' The structural changes primarily consist of replacing the many GOTOs with
|
||||
''' Do/Loop constructs to force the continual execution of the program.
|
||||
'''
|
||||
''' Because modern Basic allows multi-line If/Then blocks, many GOTO jumps were
|
||||
''' able to be eliminated and the logic was able to be moved to more relevant areas,
|
||||
''' For example, the increment/decrement of the player's balance could be in the same
|
||||
''' area as the notification of win/loss.
|
||||
'''
|
||||
''' Some modern improvements were added, primarily the inclusion of a function, which
|
||||
''' eliminated a thrice-repeated block of logic to display the card value. The archaic
|
||||
''' RND function is greatly simplified with the .NET Framework's Random class.
|
||||
'''
|
||||
''' Elementary comments are provided for non-programmers or novices.
|
||||
''' </summary>
|
||||
Module Program
|
||||
Sub Main(args As String())
|
||||
' These are the variables that will hold values during the program's execution
|
||||
Dim input As String
|
||||
Dim rnd As New Random ' You can create a new instance of an object during declaration
|
||||
Dim currentBalance As Integer = 100 ' You can set a initial value at declaration
|
||||
Dim currentWager As Integer
|
||||
Dim cardA, cardB, cardC As Integer ' You can specify multiple variables of the same type in one declaration statement
|
||||
|
||||
' Display the opening title and instructions
|
||||
' Use a preceding $ to insert calculated values within the string using {}
|
||||
Console.WriteLine($"{Space((Console.WindowWidth \ 2) - 10)}ACEY DUCEY CARD GAME")
|
||||
Console.WriteLine($"{Space((Console.WindowWidth \ 2) - 21)}CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER")
|
||||
Console.WriteLine("THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP")
|
||||
Console.WriteLine("YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING")
|
||||
Console.WriteLine("ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE")
|
||||
Console.WriteLine("A VALUE BETWEEN THE FIRST TWO.")
|
||||
Console.WriteLine("IF YOU DO NOT WANT TO BET, INPUT A 0")
|
||||
|
||||
Do ' This loop continues as long as the player wants to keep playing
|
||||
|
||||
Do ' This loop continues as long as the player has money to play
|
||||
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine($"YOU NOW HAVE {currentBalance} DOLLARS.")
|
||||
Console.WriteLine("")
|
||||
|
||||
Console.WriteLine("HERE ARE YOUR NEXT TWO CARDS:")
|
||||
|
||||
' We need to ensure that card B is a higher value for our later comparison,
|
||||
' so we will loop until we have two cards that meet this criteria
|
||||
Do
|
||||
cardA = rnd.Next(2, 14)
|
||||
cardB = rnd.Next(2, 14)
|
||||
|
||||
Loop While cardA > cardB
|
||||
|
||||
' We use a function to display the text value of the numeric card value
|
||||
' because we do this 3 times and a function reduces repetition of code
|
||||
Console.WriteLine(DisplayCard(cardA))
|
||||
Console.WriteLine(DisplayCard(cardB))
|
||||
|
||||
Do ' This loop continues until the player provides a valid wager value
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("WHAT IS YOUR BET")
|
||||
|
||||
currentWager = 0
|
||||
input = Console.ReadLine
|
||||
|
||||
' Any input from the console is a string, but we require a number.
|
||||
' Test the input to make sure it is a numeric value.
|
||||
If Integer.TryParse(input, currentWager) Then
|
||||
' Test to ensure the player has not wagered more than their balance
|
||||
If currentWager > currentBalance Then
|
||||
Console.WriteLine("SORRY, MY FRIEND, BUT YOU BET TOO MUCH.")
|
||||
Console.WriteLine($"YOU HAVE ONLY {currentBalance} DOLLARS TO BET.")
|
||||
|
||||
Else
|
||||
' The player has provided a numeric value that is less/equal to their balance,
|
||||
' exit the loop and continue play
|
||||
Exit Do
|
||||
|
||||
End If ' check player balance
|
||||
|
||||
End If ' check numeric input
|
||||
|
||||
Loop ' wager loop
|
||||
|
||||
' If the player is wagering, draw the third card, otherwise, mock them.
|
||||
If currentWager > 0 Then
|
||||
cardC = rnd.Next(2, 14)
|
||||
|
||||
Console.WriteLine(DisplayCard(cardC))
|
||||
|
||||
' The effort we made to have two cards in numeric order earlier makes this check easier,
|
||||
' otherwise we would have to have a second check in the opposite direction
|
||||
If cardC < cardA OrElse cardC >= cardB Then
|
||||
Console.WriteLine("SORRY, YOU LOSE")
|
||||
currentBalance -= currentWager ' Shorthand code to decrement a number (currentBalance=currentBalance - currentWager)
|
||||
|
||||
Else
|
||||
Console.WriteLine("YOU WIN!!!")
|
||||
currentBalance += currentWager ' Shorthand code to increment a number (currentBalance=currentBalance + currentWager)
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
Console.WriteLine("CHICKEN!!")
|
||||
Console.WriteLine("")
|
||||
|
||||
End If
|
||||
|
||||
Loop While currentBalance > 0 ' loop as long as the player has money
|
||||
|
||||
' At this point, the player has no money (currentBalance=0). Inform them of such.
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("SORRY, FRIEND, BUT YOU BLEW YOUR WAD.")
|
||||
Console.WriteLine("")
|
||||
Console.WriteLine("")
|
||||
|
||||
' We will loop to ensure the player provides some answer.
|
||||
Do
|
||||
Console.WriteLine("TRY AGAIN (YES OR NO)")
|
||||
Console.WriteLine("")
|
||||
|
||||
input = Console.ReadLine
|
||||
|
||||
Loop While String.IsNullOrWhiteSpace(input)
|
||||
|
||||
' We will assume that the player wants to play again only if they answer yes.
|
||||
' (yeah and ya are valid as well, because we only check the first letter)
|
||||
If input.Substring(0, 1).Equals("y", StringComparison.CurrentCultureIgnoreCase) Then ' This allows upper and lower case to be entered.
|
||||
currentBalance = 100 ' Reset the players balance before restarting
|
||||
|
||||
Else
|
||||
' Exit the outer loop which will end the game.
|
||||
Exit Do
|
||||
|
||||
End If
|
||||
|
||||
Loop ' The full game loop
|
||||
|
||||
Console.WriteLine("O.K., HOPE YOU HAD FUN!")
|
||||
|
||||
End Sub
|
||||
|
||||
' This function is called for each of the 3 cards used in the game.
|
||||
' The input and the output are both consistent, making it a good candidate for a function.
|
||||
Private Function DisplayCard(value As Integer) As String
|
||||
' We check the value of the input and run a block of code for whichever
|
||||
' evaluation matches
|
||||
Select Case value
|
||||
Case 2 To 10 ' Case statements can be ranges of values, also multiple values (Case 2,3,4,5,6,7,8,9,10)
|
||||
Return value.ToString
|
||||
|
||||
Case 11
|
||||
Return "JACK"
|
||||
|
||||
Case 12
|
||||
Return "QUEEN"
|
||||
|
||||
Case 13
|
||||
Return "KING"
|
||||
|
||||
Case 14
|
||||
Return "ACE"
|
||||
|
||||
End Select
|
||||
|
||||
' Although we have full knowledge of the program and never plan to send an invalid
|
||||
' card value, it's important to provide a message for the next developer who won't
|
||||
Throw New ArgumentOutOfRangeException("Card value must be between 2 and 14")
|
||||
|
||||
End Function
|
||||
|
||||
End Module
|
||||
21
01_Acey_Ducey/vbnet/Program.vb
Normal file
21
01_Acey_Ducey/vbnet/Program.vb
Normal file
@@ -0,0 +1,21 @@
|
||||
Imports System
|
||||
|
||||
''' <summary>
|
||||
''' This is a modern adapation of Acey Ducey from BASIC Computer Games.
|
||||
'''
|
||||
''' The structural changes primarily consist of replacing the many GOTOs with
|
||||
''' Do/Loop constructs to force the continual execution of the program.
|
||||
'''
|
||||
''' Some modern improvements were added, primarily the inclusion of a multiple
|
||||
''' subroutines and functions, which eliminates repeated logic and reduces
|
||||
''' then need for nested loops.
|
||||
'''
|
||||
''' The archaic RND function is greatly simplified with the .NET Framework's Random class.
|
||||
'''
|
||||
''' Elementary comments are provided for non-programmers or novices.
|
||||
''' </summary>
|
||||
Module Program
|
||||
Sub Main()
|
||||
Call New AceyDucey().Play()
|
||||
End Sub
|
||||
End Module
|
||||
22
02_Amazing/vbnet/Amazing.sln
Normal file
22
02_Amazing/vbnet/Amazing.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Amazing", "Amazing.vbproj", "{FB9DF301-CB34-4C9A-8823-F034303F5DA3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FB9DF301-CB34-4C9A-8823-F034303F5DA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FB9DF301-CB34-4C9A-8823-F034303F5DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FB9DF301-CB34-4C9A-8823-F034303F5DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB9DF301-CB34-4C9A-8823-F034303F5DA3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
02_Amazing/vbnet/Amazing.vbproj
Normal file
8
02_Amazing/vbnet/Amazing.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Amazing</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -2,159 +2,244 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* ANIMAL
|
||||
* <p>
|
||||
* Converted from BASIC to Java by Aldrin Misquitta (@aldrinm)
|
||||
* The original BASIC program uses an array to maintain the questions and answers and to decide which question to
|
||||
* ask next. Updated this Java implementation to use a tree instead of the earlier faulty one based on a list (thanks @patimen).
|
||||
*/
|
||||
public class Animal {
|
||||
|
||||
public static void main(String[] args) {
|
||||
printIntro();
|
||||
Scanner scan = new Scanner(System.in);
|
||||
public static void main(String[] args) {
|
||||
printIntro();
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
List<Question> questions = new ArrayList<>();
|
||||
questions.add(new Question("DOES IT SWIM", "FISH", "BIRD"));
|
||||
Node root = new QuestionNode("DOES IT SWIM",
|
||||
new AnimalNode("FISH"), new AnimalNode("BIRD"));
|
||||
|
||||
boolean stopGame = false;
|
||||
while (!stopGame) {
|
||||
String choice = readMainChoice(scan);
|
||||
switch (choice) {
|
||||
case "LIST":
|
||||
printKnownAnimals(questions);
|
||||
break;
|
||||
case "Q":
|
||||
case "QUIT":
|
||||
stopGame = true;
|
||||
break;
|
||||
default:
|
||||
if (choice.toUpperCase(Locale.ROOT).startsWith("Y")) {
|
||||
int k = 0;
|
||||
boolean correctGuess = false;
|
||||
while (questions.size() > k && !correctGuess) {
|
||||
Question question = questions.get(k);
|
||||
correctGuess = askQuestion(question, scan);
|
||||
if (correctGuess) {
|
||||
System.out.println("WHY NOT TRY ANOTHER ANIMAL?");
|
||||
} else {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
boolean stopGame = false;
|
||||
while (!stopGame) {
|
||||
String choice = readMainChoice(scan);
|
||||
switch (choice) {
|
||||
case "TREE":
|
||||
printTree(root);
|
||||
break;
|
||||
case "LIST":
|
||||
printKnownAnimals(root);
|
||||
break;
|
||||
case "Q":
|
||||
case "QUIT":
|
||||
stopGame = true;
|
||||
break;
|
||||
default:
|
||||
if (choice.toUpperCase(Locale.ROOT).startsWith("Y")) {
|
||||
Node current = root; //where we are in the question tree
|
||||
Node previous; //keep track of parent of current in order to place new questions later on.
|
||||
|
||||
if (!correctGuess) {
|
||||
askForInformationAndSave(scan, questions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (current instanceof QuestionNode) {
|
||||
var currentQuestion = (QuestionNode) current;
|
||||
var reply = askQuestionAndGetReply(currentQuestion, scan);
|
||||
|
||||
}
|
||||
previous = current;
|
||||
current = reply ? currentQuestion.getTrueAnswer() : currentQuestion.getFalseAnswer();
|
||||
if (current instanceof AnimalNode) {
|
||||
//We have reached a animal node, so offer it as the guess
|
||||
var currentAnimal = (AnimalNode) current;
|
||||
System.out.printf("IS IT A %s ? ", currentAnimal.getAnimal());
|
||||
var animalGuessResponse = readYesOrNo(scan);
|
||||
if (animalGuessResponse) {
|
||||
//we guessed right! end this round
|
||||
System.out.println("WHY NOT TRY ANOTHER ANIMAL?");
|
||||
} else {
|
||||
//we guessed wrong :(, ask for feedback
|
||||
//cast previous to QuestionNode since we know at this point that it is not a leaf node
|
||||
askForInformationAndSave(scan, currentAnimal, (QuestionNode) previous, reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void askForInformationAndSave(Scanner scan, List<Question> questions) {
|
||||
//Failed to get it right and ran out of questions
|
||||
//Let's ask the user for the new information
|
||||
System.out.print("THE ANIMAL YOU WERE THINKING OF WAS A ");
|
||||
String animal = scan.nextLine();
|
||||
System.out.printf("PLEASE TYPE IN A QUESTION THAT WOULD DISTINGUISH A %s FROM A %s ", animal, questions.get(
|
||||
questions.size() - 1).falseAnswer);
|
||||
String newQuestion = scan.nextLine();
|
||||
System.out.printf("FOR A %s THE ANSWER WOULD BE ", animal);
|
||||
boolean newAnswer = readYesOrNo(scan);
|
||||
//Add it to our list
|
||||
addNewAnimal(questions, animal, newQuestion, newAnswer);
|
||||
}
|
||||
/**
|
||||
* Prompt for information about the animal we got wrong
|
||||
* @param current The animal that we guessed wrong
|
||||
* @param previous The root of current
|
||||
* @param previousToCurrentDecisionChoice Whether it was a Y or N answer that got us here. true = Y, false = N
|
||||
*/
|
||||
private static void askForInformationAndSave(Scanner scan, AnimalNode current, QuestionNode previous, boolean previousToCurrentDecisionChoice) {
|
||||
//Failed to get it right and ran out of questions
|
||||
//Let's ask the user for the new information
|
||||
System.out.print("THE ANIMAL YOU WERE THINKING OF WAS A ");
|
||||
String animal = scan.nextLine();
|
||||
System.out.printf("PLEASE TYPE IN A QUESTION THAT WOULD DISTINGUISH A %s FROM A %s ", animal, current.getAnimal());
|
||||
String newQuestion = scan.nextLine();
|
||||
System.out.printf("FOR A %s THE ANSWER WOULD BE ", animal);
|
||||
boolean newAnswer = readYesOrNo(scan);
|
||||
//Add it to our question store
|
||||
addNewAnimal(current, previous, animal, newQuestion, newAnswer, previousToCurrentDecisionChoice);
|
||||
}
|
||||
|
||||
private static void addNewAnimal(List<Question> questions, String animal, String newQuestion, boolean newAnswer) {
|
||||
Question lastQuestion = questions.get(questions.size() - 1);
|
||||
String lastAnimal = lastQuestion.falseAnswer;
|
||||
lastQuestion.falseAnswer = null; //remove the false option to indicate that there is a next question
|
||||
private static void addNewAnimal(Node current,
|
||||
QuestionNode previous,
|
||||
String animal,
|
||||
String newQuestion,
|
||||
boolean newAnswer,
|
||||
boolean previousToCurrentDecisionChoice) {
|
||||
var animalNode = new AnimalNode(animal);
|
||||
var questionNode = new QuestionNode(newQuestion,
|
||||
newAnswer ? animalNode : current,
|
||||
!newAnswer ? animalNode : current);
|
||||
|
||||
Question newOption;
|
||||
if (newAnswer) {
|
||||
newOption = new Question(newQuestion, animal, lastAnimal);
|
||||
} else {
|
||||
newOption = new Question(newQuestion, lastAnimal, animal);
|
||||
}
|
||||
questions.add(newOption);
|
||||
}
|
||||
if (previous != null) {
|
||||
if (previousToCurrentDecisionChoice) {
|
||||
previous.setTrueAnswer(questionNode);
|
||||
} else {
|
||||
previous.setFalseAnswer(questionNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean askQuestion(Question question, Scanner scanner) {
|
||||
System.out.printf("%s ? ", question.question);
|
||||
private static boolean askQuestionAndGetReply(QuestionNode questionNode, Scanner scanner) {
|
||||
System.out.printf("%s ? ", questionNode.question);
|
||||
return readYesOrNo(scanner);
|
||||
}
|
||||
|
||||
boolean chosenAnswer = readYesOrNo(scanner);
|
||||
if (chosenAnswer) {
|
||||
if (question.trueAnswer != null) {
|
||||
System.out.printf("IS IT A %s ? ", question.trueAnswer);
|
||||
return readYesOrNo(scanner);
|
||||
}
|
||||
//else go to the next question
|
||||
} else {
|
||||
if (question.falseAnswer != null) {
|
||||
System.out.printf("IS IT A %s ? ", question.falseAnswer);
|
||||
return readYesOrNo(scanner);
|
||||
}
|
||||
//else go to the next question
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static boolean readYesOrNo(Scanner scanner) {
|
||||
boolean validAnswer = false;
|
||||
Boolean choseAnswer = null;
|
||||
while (!validAnswer) {
|
||||
String answer = scanner.nextLine();
|
||||
if (answer.toUpperCase(Locale.ROOT).startsWith("Y")) {
|
||||
validAnswer = true;
|
||||
choseAnswer = true;
|
||||
} else if (answer.toUpperCase(Locale.ROOT).startsWith("N")) {
|
||||
validAnswer = true;
|
||||
choseAnswer = false;
|
||||
}
|
||||
}
|
||||
return choseAnswer;
|
||||
}
|
||||
|
||||
private static boolean readYesOrNo(Scanner scanner) {
|
||||
boolean validAnswer = false;
|
||||
Boolean choseAnswer = null;
|
||||
while (!validAnswer) {
|
||||
String answer = scanner.nextLine();
|
||||
if (answer.toUpperCase(Locale.ROOT).startsWith("Y")) {
|
||||
validAnswer = true;
|
||||
choseAnswer = true;
|
||||
} else if (answer.toUpperCase(Locale.ROOT).startsWith("N")) {
|
||||
validAnswer = true;
|
||||
choseAnswer = false;
|
||||
}
|
||||
}
|
||||
return choseAnswer;
|
||||
}
|
||||
private static void printKnownAnimals(Node root) {
|
||||
System.out.println("\nANIMALS I ALREADY KNOW ARE:");
|
||||
|
||||
private static void printKnownAnimals(List<Question> questions) {
|
||||
System.out.println("\nANIMALS I ALREADY KNOW ARE:");
|
||||
List<String> animals = new ArrayList<>();
|
||||
questions.forEach(q -> {
|
||||
if (q.trueAnswer != null) {
|
||||
animals.add(q.trueAnswer);
|
||||
}
|
||||
if (q.falseAnswer != null) {
|
||||
animals.add(q.falseAnswer);
|
||||
}
|
||||
});
|
||||
System.out.println(String.join("\t\t", animals));
|
||||
}
|
||||
List<AnimalNode> leafNodes = collectLeafNodes(root);
|
||||
String allAnimalsString = leafNodes.stream().map(AnimalNode::getAnimal).collect(Collectors.joining("\t\t"));
|
||||
|
||||
private static String readMainChoice(Scanner scan) {
|
||||
System.out.print("ARE YOU THINKING OF AN ANIMAL ? ");
|
||||
return scan.nextLine();
|
||||
}
|
||||
System.out.println(allAnimalsString);
|
||||
}
|
||||
|
||||
private static void printIntro() {
|
||||
System.out.println(" ANIMAL");
|
||||
System.out.println(" CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
|
||||
System.out.println("\n\n");
|
||||
System.out.println("PLAY 'GUESS THE ANIMAL'");
|
||||
System.out.println("\n");
|
||||
System.out.println("THINK OF AN ANIMAL AND THE COMPUTER WILL TRY TO GUESS IT.");
|
||||
}
|
||||
//Traverse the tree and collect all the leaf nodes, which basically have all the animals.
|
||||
private static List<AnimalNode> collectLeafNodes(Node root) {
|
||||
List<AnimalNode> collectedNodes = new ArrayList<>();
|
||||
if (root instanceof AnimalNode) {
|
||||
collectedNodes.add((AnimalNode) root);
|
||||
} else {
|
||||
var q = (QuestionNode) root;
|
||||
collectedNodes.addAll(collectLeafNodes(q.getTrueAnswer()));
|
||||
collectedNodes.addAll(collectLeafNodes(q.getFalseAnswer()));
|
||||
}
|
||||
return collectedNodes;
|
||||
}
|
||||
|
||||
private static String readMainChoice(Scanner scan) {
|
||||
System.out.print("ARE YOU THINKING OF AN ANIMAL ? ");
|
||||
return scan.nextLine();
|
||||
}
|
||||
|
||||
private static void printIntro() {
|
||||
System.out.println(" ANIMAL");
|
||||
System.out.println(" CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
|
||||
System.out.println("\n\n");
|
||||
System.out.println("PLAY 'GUESS THE ANIMAL'");
|
||||
System.out.println("\n");
|
||||
System.out.println("THINK OF AN ANIMAL AND THE COMPUTER WILL TRY TO GUESS IT.");
|
||||
}
|
||||
|
||||
//Based on https://stackoverflow.com/a/8948691/74057
|
||||
private static void printTree(Node root) {
|
||||
StringBuilder buffer = new StringBuilder(50);
|
||||
print(root, buffer, "", "");
|
||||
System.out.println(buffer);
|
||||
}
|
||||
|
||||
private static void print(Node root, StringBuilder buffer, String prefix, String childrenPrefix) {
|
||||
buffer.append(prefix);
|
||||
buffer.append(root.toString());
|
||||
buffer.append('\n');
|
||||
|
||||
if (root instanceof QuestionNode) {
|
||||
var questionNode = (QuestionNode) root;
|
||||
print(questionNode.getTrueAnswer(), buffer, childrenPrefix + "├─Y─ ", childrenPrefix + "│ ");
|
||||
print(questionNode.getFalseAnswer(), buffer, childrenPrefix + "└─N─ ", childrenPrefix + " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Question {
|
||||
String question;
|
||||
String trueAnswer;
|
||||
String falseAnswer;
|
||||
/**
|
||||
* Base interface for all nodes in our question tree
|
||||
*/
|
||||
private interface Node {
|
||||
}
|
||||
|
||||
public Question(String question, String trueAnswer, String falseAnswer) {
|
||||
this.question = question;
|
||||
this.trueAnswer = trueAnswer;
|
||||
this.falseAnswer = falseAnswer;
|
||||
}
|
||||
}
|
||||
private static class QuestionNode implements Node {
|
||||
private final String question;
|
||||
private Node trueAnswer;
|
||||
private Node falseAnswer;
|
||||
|
||||
public QuestionNode(String question, Node trueAnswer, Node falseAnswer) {
|
||||
this.question = question;
|
||||
this.trueAnswer = trueAnswer;
|
||||
this.falseAnswer = falseAnswer;
|
||||
}
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public Node getTrueAnswer() {
|
||||
return trueAnswer;
|
||||
}
|
||||
|
||||
public void setTrueAnswer(Node trueAnswer) {
|
||||
this.trueAnswer = trueAnswer;
|
||||
}
|
||||
|
||||
public Node getFalseAnswer() {
|
||||
return falseAnswer;
|
||||
}
|
||||
|
||||
public void setFalseAnswer(Node falseAnswer) {
|
||||
this.falseAnswer = falseAnswer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Question{'" + question + "'}";
|
||||
}
|
||||
}
|
||||
|
||||
private static class AnimalNode implements Node {
|
||||
private final String animal;
|
||||
|
||||
public AnimalNode(String animal) {
|
||||
this.animal = animal;
|
||||
}
|
||||
|
||||
public String getAnimal() {
|
||||
return animal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Animal{'" + animal + "'}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
27
03_Animal/vbnet/Animal.Tests/Animal.Tests.vbproj
Normal file
27
03_Animal/vbnet/Animal.Tests/Animal.Tests.vbproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Animal.Tests</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<OptionStrict>On</OptionStrict>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Animal\Animal.vbproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
65
03_Animal/vbnet/Animal.Tests/MockConsole.vb
Normal file
65
03_Animal/vbnet/Animal.Tests/MockConsole.vb
Normal file
@@ -0,0 +1,65 @@
|
||||
Imports System.IO
|
||||
|
||||
Public Class MockConsole
|
||||
Inherits ConsoleAdapterBase
|
||||
|
||||
Private inputs As Queue(Of String)
|
||||
Public ReadOnly Lines As New List(Of (line As String, centered As Boolean)) From {
|
||||
("", False)
|
||||
}
|
||||
|
||||
' TODO it's possible to clear all the lines, and we'd have to check once again in WriteString and WriteCenteredLine if there are any lines
|
||||
|
||||
Sub New(Inputs As IEnumerable(Of String))
|
||||
Me.inputs = New Queue(Of String)(Inputs)
|
||||
End Sub
|
||||
|
||||
Private Sub CheckLinesInitialized()
|
||||
If Lines.Count = 0 Then Lines.Add(("", False))
|
||||
End Sub
|
||||
|
||||
Private Sub WriteString(s As String, Optional centered As Boolean = False)
|
||||
If s Is Nothing Then Return
|
||||
CheckLinesInitialized()
|
||||
s.Split(Environment.NewLine).ForEach(Sub(line, index)
|
||||
If index = 0 Then
|
||||
Dim currentLast = Lines(Lines.Count - 1)
|
||||
' centered should never come from the current last line
|
||||
' if WriteCenteredLine is called, it immediately creates a new line
|
||||
Lines(Lines.Count - 1) = (currentLast.line + line, centered)
|
||||
Else
|
||||
Lines.Add((line, centered))
|
||||
End If
|
||||
End Sub)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Write(value As Object)
|
||||
WriteString(value?.ToString)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub WriteLine(value As Object)
|
||||
WriteString(value?.ToString)
|
||||
WriteLine()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub WriteLine()
|
||||
Lines.Add(("", False))
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub WriteCenteredLine(value As Object)
|
||||
If Lines.Count = 0 Then Lines.Add(("", False))
|
||||
Dim currentLast = Lines(Lines.Count - 1).line
|
||||
If currentLast.Length > 0 Then Throw New InvalidOperationException("Can only write centered line if cursor is at start of line.")
|
||||
WriteString(value?.ToString, True)
|
||||
WriteLine()
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ReadLine() As String
|
||||
' Indicates the end of a test run, for programs which loop endlessly
|
||||
If inputs.Count = 0 Then Throw New EndOfStreamException("End of inputs")
|
||||
|
||||
Dim nextInput = inputs.Dequeue.Trim
|
||||
WriteLine(nextInput)
|
||||
Return nextInput
|
||||
End Function
|
||||
End Class
|
||||
80
03_Animal/vbnet/Animal.Tests/TestContainer.vb
Normal file
80
03_Animal/vbnet/Animal.Tests/TestContainer.vb
Normal file
@@ -0,0 +1,80 @@
|
||||
Imports Xunit
|
||||
Imports Animal
|
||||
Imports System.IO
|
||||
|
||||
Public Class TestContainer
|
||||
Private Shared Function ResponseVariantExpander(src As IEnumerable(Of String)) As TheoryData(Of String)
|
||||
Dim theoryData = New TheoryData(Of String)
|
||||
src.
|
||||
SelectMany(Function(x) {x, x.Substring(0, 1)}).
|
||||
SelectMany(Function(x) {
|
||||
x,
|
||||
x.ToUpperInvariant,
|
||||
x.ToLowerInvariant,
|
||||
x.ToTitleCase,
|
||||
x.ToReverseCase
|
||||
}).
|
||||
Distinct.
|
||||
ForEach(Sub(x) theoryData.Add(x))
|
||||
Return theoryData
|
||||
End Function
|
||||
Private Shared YesVariantsThepryData As TheoryData(Of String) = ResponseVariantExpander({"yes", "true", "1"})
|
||||
Private Shared Function YesVariants() As TheoryData(Of String)
|
||||
Return YesVariantsThepryData
|
||||
End Function
|
||||
Private Shared NoVariantsThepryData As TheoryData(Of String) = ResponseVariantExpander({"no", "false", "0"})
|
||||
Private Shared Function NoVariants() As TheoryData(Of String)
|
||||
Return NoVariantsThepryData
|
||||
End Function
|
||||
|
||||
''' <summary>Test LIST variants</summary>
|
||||
<Theory>
|
||||
<InlineData("LIST")>
|
||||
<InlineData("list")>
|
||||
<InlineData("List")>
|
||||
<InlineData("lIST")>
|
||||
Sub List(listResponse As String)
|
||||
Dim console As New MockConsole({listResponse})
|
||||
Dim game As New Game(console)
|
||||
Assert.Throws(Of EndOfStreamException)(Sub() game.BeginLoop())
|
||||
Assert.Equal(
|
||||
{
|
||||
"ANIMALS I ALREADY KNOW ARE:",
|
||||
"FISH BIRD "
|
||||
},
|
||||
console.Lines.Slice(-4, -2).Select(Function(x) x.line)
|
||||
)
|
||||
End Sub
|
||||
|
||||
'' <summary>Test YES variants</summary>
|
||||
<Theory>
|
||||
<MemberData(NameOf(YesVariants))>
|
||||
Sub YesVariant(yesVariant As String)
|
||||
Dim console As New MockConsole({yesVariant})
|
||||
Dim game As New Game(console)
|
||||
Assert.Throws(Of EndOfStreamException)(Sub() game.BeginLoop())
|
||||
Assert.Equal(
|
||||
{
|
||||
$"ARE YOU THINKING OF AN ANIMAL? {yesVariant}",
|
||||
"DOES IT SWIM? "
|
||||
},
|
||||
console.Lines.Slice(-2, 0).Select(Function(x) x.line)
|
||||
)
|
||||
End Sub
|
||||
|
||||
'' <summary>Test NO variants</summary>
|
||||
<Theory>
|
||||
<MemberData(NameOf(NoVariants))>
|
||||
Sub NoVariant(noVariant As String)
|
||||
Dim console As New MockConsole({"y", noVariant})
|
||||
Dim game As New Game(console)
|
||||
Assert.Throws(Of EndOfStreamException)(Sub() game.BeginLoop())
|
||||
Assert.Equal(
|
||||
{
|
||||
$"DOES IT SWIM? {noVariant}",
|
||||
"IS IT A BIRD? "
|
||||
},
|
||||
console.Lines.Slice(-2, 0).Select(Function(x) x.line)
|
||||
)
|
||||
End Sub
|
||||
End Class
|
||||
31
03_Animal/vbnet/Animal.sln
Normal file
31
03_Animal/vbnet/Animal.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.32112.339
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Animal", "Animal\Animal.vbproj", "{5517E4CE-BCF9-4D1F-9A17-B620C1B96B0D}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Animal.Tests", "Animal.Tests\Animal.Tests.vbproj", "{3986C6A2-77D4-4F00-B3CF-F5736C623B1E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5517E4CE-BCF9-4D1F-9A17-B620C1B96B0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5517E4CE-BCF9-4D1F-9A17-B620C1B96B0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5517E4CE-BCF9-4D1F-9A17-B620C1B96B0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5517E4CE-BCF9-4D1F-9A17-B620C1B96B0D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3986C6A2-77D4-4F00-B3CF-F5736C623B1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3986C6A2-77D4-4F00-B3CF-F5736C623B1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3986C6A2-77D4-4F00-B3CF-F5736C623B1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3986C6A2-77D4-4F00-B3CF-F5736C623B1E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {88469A47-E30C-4763-A325-074101D16608}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
9
03_Animal/vbnet/Animal/Animal.vbproj
Normal file
9
03_Animal/vbnet/Animal/Animal.vbproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Animal</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
<OptionStrict>On</OptionStrict>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
29
03_Animal/vbnet/Animal/Branch.vb
Normal file
29
03_Animal/vbnet/Animal/Branch.vb
Normal file
@@ -0,0 +1,29 @@
|
||||
Public Class Branch
|
||||
Public Property Text As String
|
||||
|
||||
Public ReadOnly Property IsEnd As Boolean
|
||||
Get
|
||||
Return Yes Is Nothing AndAlso No Is Nothing
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Property Yes As Branch
|
||||
Public Property No As Branch
|
||||
|
||||
' Allows walking all the descendants recursively
|
||||
Public Iterator Function DescendantTexts() As IEnumerable(Of String)
|
||||
If Yes IsNot Nothing Then
|
||||
Yield Yes.Text
|
||||
For Each childText In Yes.DescendantTexts
|
||||
Yield childText
|
||||
Next
|
||||
End If
|
||||
|
||||
If No IsNot Nothing Then
|
||||
Yield No.Text
|
||||
For Each childText In No.DescendantTexts
|
||||
Yield childText
|
||||
Next
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
152
03_Animal/vbnet/Animal/Game.vb
Normal file
152
03_Animal/vbnet/Animal/Game.vb
Normal file
@@ -0,0 +1,152 @@
|
||||
Option Compare Text
|
||||
|
||||
Public Class Game
|
||||
' This Dictionary holds the corresponding value for each of the variants of "YES" and "NO" we accept
|
||||
' Note that the Dictionary is case-insensitive, meaning it maps "YES", "yes" and even "yEs" to True
|
||||
Private Shared ReadOnly YesNoResponses As New Dictionary(Of String, Boolean)(StringComparer.InvariantCultureIgnoreCase) From {
|
||||
{"yes", True},
|
||||
{"y", True},
|
||||
{"true", True},
|
||||
{"t", True},
|
||||
{"1", True},
|
||||
{"no", False},
|
||||
{"n", False},
|
||||
{"false", False},
|
||||
{"f", False},
|
||||
{"0", False}
|
||||
}
|
||||
|
||||
ReadOnly console As ConsoleAdapterBase
|
||||
|
||||
' The pre-initialized root branch
|
||||
ReadOnly root As New Branch With {
|
||||
.Text = "DOES IT SWIM?",
|
||||
.Yes = New Branch With {.Text = "FISH"},
|
||||
.No = New Branch With {.Text = "BIRD"}
|
||||
}
|
||||
|
||||
''' <summary>Reduces a string or console input to True, False or Nothing. Case-insensitive.</summary>
|
||||
''' <param name="s">Optional String to reduce via the same logic. If not passed in, will use console.ReadLine</param>
|
||||
''' <returns>
|
||||
''' Returns True for a "yes" response (yes, y, true, t, 1) and False for a "no" response (no, n, false, f, 0).<br/>
|
||||
''' Returns Nothing if the response doesn't match any of these.
|
||||
''' </returns>
|
||||
Private Function GetYesNo(Optional s As String = Nothing) As Boolean?
|
||||
s = If(s, console.ReadLine)
|
||||
Dim ret As Boolean
|
||||
If YesNoResponses.TryGetValue(s, ret) Then Return ret
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
Sub New(console As ConsoleAdapterBase)
|
||||
If console Is Nothing Then Throw New ArgumentNullException(NameOf(console))
|
||||
Me.console = console
|
||||
End Sub
|
||||
|
||||
|
||||
Sub BeginLoop()
|
||||
' Print the program heading
|
||||
console.WriteCenteredLine("ANIMAL")
|
||||
console.WriteCenteredLine("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
console.Write(
|
||||
"
|
||||
|
||||
|
||||
PLAY 'GUESS THE ANIMAL'
|
||||
|
||||
THINK OF AN ANIMAL AND THE COMPUTER WILL TRY TO GUESS IT.
|
||||
|
||||
")
|
||||
|
||||
Do
|
||||
console.Write("ARE YOU THINKING OF AN ANIMAL? ")
|
||||
|
||||
Dim response = console.ReadLine
|
||||
If response = "list" Then
|
||||
' List all the stored animals
|
||||
console.WriteLine(
|
||||
"
|
||||
ANIMALS I ALREADY KNOW ARE:")
|
||||
|
||||
' We're using a ForEach extension method instead of the regular For Each loop to provide the index alongside the text
|
||||
root.DescendantTexts.ForEach(Sub(text, index)
|
||||
' We want to move to the next line after every four animals
|
||||
' But for the first animal, where the index is 0, 0 Mod 4 will also return 0
|
||||
' So we have to explicitly exclude the first animal
|
||||
If index > 0 AndAlso index Mod 4 = 0 Then console.WriteLine()
|
||||
console.Write($"{text.MaxLength(15),-15}")
|
||||
End Sub)
|
||||
console.WriteLine(
|
||||
"
|
||||
")
|
||||
Continue Do
|
||||
End If
|
||||
|
||||
Dim ynResponse = GetYesNo(response)
|
||||
If ynResponse Is Nothing OrElse Not ynResponse Then Continue Do
|
||||
|
||||
Dim currentBranch = root
|
||||
Do While Not currentBranch.IsEnd
|
||||
' Branches can either be questions, or end branches
|
||||
' We have to walk the questions, prompting each time for "yes" or "no"
|
||||
console.Write($"{currentBranch.Text} ")
|
||||
Do
|
||||
ynResponse = GetYesNo()
|
||||
Loop While ynResponse Is Nothing
|
||||
|
||||
' Depending on the answer, we'll follow either the branch at "Yes" or "No"
|
||||
currentBranch = If(
|
||||
ynResponse,
|
||||
currentBranch.Yes,
|
||||
currentBranch.No
|
||||
)
|
||||
Loop
|
||||
|
||||
' Now we're at an end branch
|
||||
console.Write($"IS IT A {currentBranch.Text}? ")
|
||||
ynResponse = GetYesNo()
|
||||
If ynResponse Then ' Only if ynResponse = True will we go into this If Then
|
||||
console.WriteLine("WHY NOT TRY ANOTHER ANIMAL?")
|
||||
Continue Do
|
||||
End If
|
||||
|
||||
' Get the new animal
|
||||
console.Write("THE ANIMAL YOU WERE THINKING OF WAS A ? ")
|
||||
Dim newAnimal = console.ReadLine
|
||||
|
||||
' Get the question used to distinguish the new animal from the current end branch
|
||||
console.WriteLine(
|
||||
$"PLEASE TYPE IN A QUESTION THAT WOULD DISTINGUISH A
|
||||
{newAnimal} FROM A {currentBranch.Text}")
|
||||
Dim newQuestion = console.ReadLine
|
||||
|
||||
' Get the answer to that question, for the new animal
|
||||
' for the old animal, the answer would be the opposite
|
||||
console.Write(
|
||||
$"FOR A {newAnimal} THE ANSWER WOULD BE ? ")
|
||||
Do
|
||||
ynResponse = GetYesNo()
|
||||
Loop While ynResponse Is Nothing
|
||||
|
||||
' Create the new end branch for the new animal
|
||||
Dim newBranch = New Branch With {.Text = newAnimal}
|
||||
|
||||
' Copy over the current animal to another new end branch
|
||||
Dim currentBranchCopy = New Branch With {.Text = currentBranch.Text}
|
||||
|
||||
' Make the current branch into the distinguishing question
|
||||
currentBranch.Text = newQuestion
|
||||
|
||||
' Set the Yes and No branches of the current branch according to the answer
|
||||
If ynResponse Then
|
||||
currentBranch.Yes = newBranch
|
||||
currentBranch.No = currentBranchCopy
|
||||
Else
|
||||
currentBranch.No = newBranch
|
||||
currentBranch.Yes = currentBranchCopy
|
||||
End If
|
||||
|
||||
' TODO how do we exit?
|
||||
Loop
|
||||
End Sub
|
||||
End Class
|
||||
6
03_Animal/vbnet/Animal/Program.vb
Normal file
6
03_Animal/vbnet/Animal/Program.vb
Normal file
@@ -0,0 +1,6 @@
|
||||
Module Program
|
||||
Sub Main()
|
||||
Dim game As New Game(New ConsoleAdapter)
|
||||
game.BeginLoop()
|
||||
End Sub
|
||||
End Module
|
||||
29
03_Animal/vbnet/Animal/Shared/ConsoleAdapter.vb
Normal file
29
03_Animal/vbnet/Animal/Shared/ConsoleAdapter.vb
Normal file
@@ -0,0 +1,29 @@
|
||||
Public Class ConsoleAdapter
|
||||
Inherits ConsoleAdapterBase
|
||||
|
||||
Public Overrides Sub Write(value As Object)
|
||||
Console.Write(value)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub WriteLine(value As Object)
|
||||
Console.WriteLine(value)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub WriteLine()
|
||||
Console.WriteLine()
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub WriteCenteredLine(value As Object)
|
||||
If Console.CursorLeft <> 0 Then Throw New InvalidOperationException("Can only write centered line if cursor is at start of line.")
|
||||
Dim toWrite = If(value?.ToString, "")
|
||||
Console.WriteLine($"{Space((Console.WindowWidth - toWrite.Length) \ 2)}{toWrite}")
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ReadLine() As String
|
||||
Dim response As String
|
||||
Do
|
||||
response = Console.ReadLine
|
||||
Loop While response Is Nothing
|
||||
Return response.Trim
|
||||
End Function
|
||||
End Class
|
||||
9
03_Animal/vbnet/Animal/Shared/ConsoleAdapterBase.vb
Normal file
9
03_Animal/vbnet/Animal/Shared/ConsoleAdapterBase.vb
Normal file
@@ -0,0 +1,9 @@
|
||||
Public MustInherit Class ConsoleAdapterBase
|
||||
Public MustOverride Sub Write(value As Object)
|
||||
Public MustOverride Sub WriteLine(value As Object)
|
||||
Public MustOverride Sub WriteLine()
|
||||
Public MustOverride Sub WriteCenteredLine(value As Object)
|
||||
|
||||
''' <summary>Implementations should always return a String without leading or trailing whitespace, never Nothng</summary>
|
||||
Public MustOverride Function ReadLine() As String
|
||||
End Class
|
||||
50
03_Animal/vbnet/Animal/Shared/Extensions.vb
Normal file
50
03_Animal/vbnet/Animal/Shared/Extensions.vb
Normal file
@@ -0,0 +1,50 @@
|
||||
Imports System.Runtime.CompilerServices
|
||||
|
||||
Public Module Extensions
|
||||
<Extension> Public Sub ForEach(Of T)(src As IEnumerable(Of T), action As Action(Of T))
|
||||
For Each x In src
|
||||
action(x)
|
||||
Next
|
||||
End Sub
|
||||
<Extension> Public Sub ForEach(Of T)(src As IEnumerable(Of T), action As Action(Of T, Integer))
|
||||
Dim index As Integer
|
||||
For Each x In src
|
||||
action(x, index)
|
||||
index += 1
|
||||
Next
|
||||
End Sub
|
||||
|
||||
<Extension> Public Function MaxLength(s As String, value As Integer) As String
|
||||
If s Is Nothing Then Return Nothing
|
||||
Return s.Substring(0, Math.Min(s.Length, value))
|
||||
End Function
|
||||
|
||||
<Extension> Public Function ForceEndsWith(s As String, toAppend As String) As String
|
||||
If Not s.EndsWith(toAppend, StringComparison.OrdinalIgnoreCase) Then s += toAppend
|
||||
Return s
|
||||
End Function
|
||||
|
||||
<Extension> Public Function ToTitleCase(s As String) As String
|
||||
If s Is Nothing Then Return Nothing
|
||||
Return Char.ToUpperInvariant(s(0)) + s.Substring(1).ToUpperInvariant
|
||||
End Function
|
||||
|
||||
' https://stackoverflow.com/a/3681580/111794
|
||||
<Extension> Public Function ToReverseCase(s As String) As String
|
||||
If s Is Nothing Then Return Nothing
|
||||
Return New String(s.Select(Function(c) If(
|
||||
Not Char.IsLetter(c),
|
||||
c,
|
||||
If(
|
||||
Char.IsUpper(c), Char.ToLowerInvariant(c), Char.ToUpperInvariant(c)
|
||||
)
|
||||
)).ToArray)
|
||||
End Function
|
||||
|
||||
' https://stackoverflow.com/a/58132204/111794
|
||||
<Extension> Public Function Slice(Of T)(lst As IList(Of T), start As Integer, [end] As Integer) As T()
|
||||
start = If(start >= 0, start, lst.Count + start)
|
||||
[end] = If([end] > 0, [end], lst.Count + [end])
|
||||
Return lst.Skip(start).Take([end] - start).ToArray
|
||||
End Function
|
||||
End Module
|
||||
25
04_Awari/csharp/Awari.sln
Normal file
25
04_Awari/csharp/Awari.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.32014.148
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Awari", "Awari.csproj", "{DD161F58-D90F-481A-8275-96E01D229A70}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DD161F58-D90F-481A-8275-96E01D229A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DD161F58-D90F-481A-8275-96E01D229A70}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DD161F58-D90F-481A-8275-96E01D229A70}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD161F58-D90F-481A-8275-96E01D229A70}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7F5C288A-A6C6-4AC0-96E3-6A3B482A0947}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
04_Awari/vbnet/Awari.sln
Normal file
22
04_Awari/vbnet/Awari.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Awari", "Awari.vbproj", "{718AECEB-CC24-49C8-B620-B2F93E021C51}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{718AECEB-CC24-49C8-B620-B2F93E021C51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{718AECEB-CC24-49C8-B620-B2F93E021C51}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{718AECEB-CC24-49C8-B620-B2F93E021C51}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{718AECEB-CC24-49C8-B620-B2F93E021C51}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
04_Awari/vbnet/Awari.vbproj
Normal file
8
04_Awari/vbnet/Awari.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Awari</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,7 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>BasicComputerGames.Bagels</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
22
05_Bagels/csharp/Bagels.sln
Normal file
22
05_Bagels/csharp/Bagels.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bagels", "Bagels.csproj", "{2FC5F33F-2C4B-4707-94E5-3C9B2B633EFE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2FC5F33F-2C4B-4707-94E5-3C9B2B633EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2FC5F33F-2C4B-4707-94E5-3C9B2B633EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2FC5F33F-2C4B-4707-94E5-3C9B2B633EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2FC5F33F-2C4B-4707-94E5-3C9B2B633EFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
05_Bagels/vbnet/Bagels.sln
Normal file
22
05_Bagels/vbnet/Bagels.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bagels", "Bagels.vbproj", "{913FE7A8-B481-4EB3-8938-566BEAD5B0F2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{913FE7A8-B481-4EB3-8938-566BEAD5B0F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{913FE7A8-B481-4EB3-8938-566BEAD5B0F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{913FE7A8-B481-4EB3-8938-566BEAD5B0F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{913FE7A8-B481-4EB3-8938-566BEAD5B0F2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
05_Bagels/vbnet/Bagels.vbproj
Normal file
8
05_Bagels/vbnet/Bagels.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bagels</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31321.278
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "banner", "banner.csproj", "{9E24FA30-F2AC-4BF3-ADFB-92D3F796561C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Banner", "Banner.csproj", "{7E8612AB-AFFD-4F72-855F-8172786F28FD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -11,10 +11,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9E24FA30-F2AC-4BF3-ADFB-92D3F796561C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9E24FA30-F2AC-4BF3-ADFB-92D3F796561C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9E24FA30-F2AC-4BF3-ADFB-92D3F796561C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9E24FA30-F2AC-4BF3-ADFB-92D3F796561C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7E8612AB-AFFD-4F72-855F-8172786F28FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7E8612AB-AFFD-4F72-855F-8172786F28FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7E8612AB-AFFD-4F72-855F-8172786F28FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7E8612AB-AFFD-4F72-855F-8172786F28FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31321.278
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "banner", "banner.vbproj", "{1738D297-A04C-4E6E-8219-D9E72982C39D}"
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Banner", "Banner.vbproj", "{091ABE13-3E70-4848-B836-592F725915A3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -11,10 +11,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1738D297-A04C-4E6E-8219-D9E72982C39D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1738D297-A04C-4E6E-8219-D9E72982C39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1738D297-A04C-4E6E-8219-D9E72982C39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1738D297-A04C-4E6E-8219-D9E72982C39D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{091ABE13-3E70-4848-B836-592F725915A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{091ABE13-3E70-4848-B836-592F725915A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{091ABE13-3E70-4848-B836-592F725915A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{091ABE13-3E70-4848-B836-592F725915A3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>banner</RootNamespace>
|
||||
<RootNamespace>Banner</RootNamespace>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
9
07_Basketball/csharp/Basketball.csproj
Normal file
9
07_Basketball/csharp/Basketball.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
07_Basketball/csharp/Basketball.sln
Normal file
22
07_Basketball/csharp/Basketball.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basketball", "Basketball.csproj", "{00D03FB3-B485-480F-B14D-746371BDE08B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{00D03FB3-B485-480F-B14D-746371BDE08B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{00D03FB3-B485-480F-B14D-746371BDE08B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{00D03FB3-B485-480F-B14D-746371BDE08B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{00D03FB3-B485-480F-B14D-746371BDE08B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
07_Basketball/vbnet/Basketball.sln
Normal file
22
07_Basketball/vbnet/Basketball.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Basketball", "Basketball.vbproj", "{09C533F2-4874-4BA4-9F80-BBE9E8E17456}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{09C533F2-4874-4BA4-9F80-BBE9E8E17456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{09C533F2-4874-4BA4-9F80-BBE9E8E17456}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{09C533F2-4874-4BA4-9F80-BBE9E8E17456}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{09C533F2-4874-4BA4-9F80-BBE9E8E17456}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
07_Basketball/vbnet/Basketball.vbproj
Normal file
8
07_Basketball/vbnet/Basketball.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Basketball</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31321.278
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.32014.148
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "batnum", "batnum.vbproj", "{D577E429-F84D-4E84-86E7-E6526CFD5FD9}"
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Batnum", "Batnum.vbproj", "{D577E429-F84D-4E84-86E7-E6526CFD5FD9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>batnum</RootNamespace>
|
||||
<RootNamespace>Batnum</RootNamespace>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
167
09_Battle/python/battle.py
Normal file
167
09_Battle/python/battle.py
Normal file
@@ -0,0 +1,167 @@
|
||||
#!/usr/bin/env python3
|
||||
from random import randrange
|
||||
from typing import List, Tuple
|
||||
|
||||
PointType = Tuple[int, int]
|
||||
VectorType = PointType
|
||||
SeaType = Tuple[List[int], ...]
|
||||
|
||||
SEA_WIDTH = 6
|
||||
DESTROYER_LENGTH = 2
|
||||
CRUISER_LENGTH = 3
|
||||
AIRCRAFT_CARRIER_LENGTH = 4
|
||||
|
||||
|
||||
def random_vector() -> Tuple[int, int]:
|
||||
while True:
|
||||
vector = (randrange(-1, 2), randrange(-1, 2))
|
||||
|
||||
if vector == (0, 0):
|
||||
# We can't have a zero vector, so try again
|
||||
continue
|
||||
|
||||
return vector
|
||||
|
||||
|
||||
def add_vector(point: PointType, vector: VectorType) -> PointType:
|
||||
return (point[0] + vector[0], point[1] + vector[1])
|
||||
|
||||
|
||||
def place_ship(sea: SeaType, size: int, code: int) -> None:
|
||||
while True:
|
||||
start = (randrange(1, SEA_WIDTH + 1), randrange(1, SEA_WIDTH + 1))
|
||||
vector = random_vector()
|
||||
|
||||
# Get potential ship points
|
||||
point = start
|
||||
points = []
|
||||
|
||||
for _ in range(size):
|
||||
point = add_vector(point, vector)
|
||||
points.append(point)
|
||||
|
||||
if (not all([is_within_sea(point, sea) for point in points]) or
|
||||
any([value_at(point, sea) for point in points])):
|
||||
# ship out of bounds or crosses other ship, trying again
|
||||
continue
|
||||
|
||||
# We found a valid spot, so actually place it now
|
||||
for point in points:
|
||||
set_value_at(code, point, sea)
|
||||
|
||||
break
|
||||
|
||||
|
||||
def print_encoded_sea(sea: SeaType) -> None:
|
||||
for x in range(len(sea)):
|
||||
print(' '.join([str(sea[y][x]) for y in range(len(sea) - 1, -1, -1)]))
|
||||
|
||||
|
||||
def is_within_sea(point: PointType, sea: SeaType) -> bool:
|
||||
return (1 <= point[0] <= len(sea)) and (1 <= point[1] <= len(sea))
|
||||
|
||||
|
||||
def has_ship(sea: SeaType, code: int) -> bool:
|
||||
return any(code in row for row in sea)
|
||||
|
||||
|
||||
def count_sunk(sea: SeaType, *codes: int) -> int:
|
||||
return sum(not has_ship(sea, code) for code in codes)
|
||||
|
||||
|
||||
def value_at(point: PointType, sea: SeaType) -> int:
|
||||
return sea[point[1] - 1][point[0] -1]
|
||||
|
||||
|
||||
def set_value_at(value: int, point: PointType, sea: SeaType) -> None:
|
||||
sea[point[1] - 1][point[0] -1] = value
|
||||
|
||||
|
||||
def get_next_target(sea: SeaType) -> PointType:
|
||||
while True:
|
||||
try:
|
||||
guess = input('? ')
|
||||
point = guess.split(',')
|
||||
|
||||
if len(point) != 2:
|
||||
raise ValueError()
|
||||
|
||||
point = (int(point[0]), int(point[1]))
|
||||
|
||||
if not is_within_sea(point, sea):
|
||||
raise ValueError()
|
||||
|
||||
return point
|
||||
except ValueError:
|
||||
print(f'INVALID. SPECIFY TWO NUMBERS FROM 1 TO {len(sea)}, SEPARATED BY A COMMA.')
|
||||
|
||||
|
||||
def setup_ships(sea: SeaType):
|
||||
place_ship(sea, DESTROYER_LENGTH, 1)
|
||||
place_ship(sea, DESTROYER_LENGTH, 2)
|
||||
place_ship(sea, CRUISER_LENGTH, 3)
|
||||
place_ship(sea, CRUISER_LENGTH, 4)
|
||||
place_ship(sea, AIRCRAFT_CARRIER_LENGTH, 5)
|
||||
place_ship(sea, AIRCRAFT_CARRIER_LENGTH, 6)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sea = tuple(([0 for _ in range(SEA_WIDTH)] for _ in range(SEA_WIDTH)))
|
||||
setup_ships(sea)
|
||||
print(f'''
|
||||
BATTLE
|
||||
CREATIVE COMPUTING MORRISTOWN, NEW JERSEY
|
||||
|
||||
THE FOLLOWING CODE OF THE BAD GUYS' FLEET DISPOSITION
|
||||
HAS BEEN CAPTURED BUT NOT DECODED:
|
||||
|
||||
''')
|
||||
print_encoded_sea(sea)
|
||||
print('''
|
||||
|
||||
DE-CODE IT AND USE IT IF YOU CAN
|
||||
BUT KEEP THE DE-CODING METHOD A SECRET.
|
||||
|
||||
START GAME''')
|
||||
splashes = 0
|
||||
hits = 0
|
||||
|
||||
while True:
|
||||
target = get_next_target(sea)
|
||||
target_value = value_at(target, sea)
|
||||
|
||||
if target_value < 0:
|
||||
print(f'YOU ALREADY PUT A HOLE IN SHIP NUMBER {abs(target_value)} AT THAT POINT.')
|
||||
|
||||
if target_value <= 0:
|
||||
print('SPLASH! TRY AGAIN.')
|
||||
splashes += 1
|
||||
continue
|
||||
|
||||
print(f'A DIRECT HIT ON SHIP NUMBER {target_value}')
|
||||
hits += 1
|
||||
set_value_at(-target_value, target, sea)
|
||||
|
||||
if not has_ship(sea, target_value):
|
||||
print('AND YOU SUNK IT. HURRAH FOR THE GOOD GUYS.')
|
||||
print('SO FAR, THE BAD GUYS HAVE LOST')
|
||||
print(f'{count_sunk(sea, 1, 2)} DESTROYER(S),',
|
||||
f'{count_sunk(sea, 3, 4)} CRUISER(S),',
|
||||
f'AND {count_sunk(sea, 5, 6)} AIRCRAFT CARRIER(S).')
|
||||
|
||||
if any(has_ship(sea, code) for code in range(1, 7)):
|
||||
print(f'YOUR CURRENT SPLASH/HIT RATIO IS {splashes}/{hits}')
|
||||
continue
|
||||
|
||||
print('YOU HAVE TOTALLY WIPED OUT THE BAD GUYS\' FLEET '
|
||||
f'WITH A FINAL SPLASH/HIT RATIO OF {splashes}/{hits}')
|
||||
|
||||
if not splashes:
|
||||
print('CONGRATULATIONS -- A DIRECT HIT EVERY TIME.')
|
||||
|
||||
print("\n****************************")
|
||||
break
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
203
09_Battle/python/battle_oo.py
Normal file
203
09_Battle/python/battle_oo.py
Normal file
@@ -0,0 +1,203 @@
|
||||
#!/usr/bin/env python3
|
||||
from dataclasses import dataclass
|
||||
from random import randrange
|
||||
|
||||
|
||||
DESTROYER_LENGTH = 2
|
||||
CRUISER_LENGTH = 3
|
||||
AIRCRAFT_CARRIER_LENGTH = 4
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Point:
|
||||
x: int
|
||||
y: int
|
||||
|
||||
@classmethod
|
||||
def random(cls, start: int, stop: int) -> 'Point':
|
||||
return Point(randrange(start, stop), randrange(start, stop))
|
||||
|
||||
def __add__(self, vector: 'Vector') -> 'Point':
|
||||
return Point(self.x + vector.x, self.y + vector.y)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Vector:
|
||||
x: int
|
||||
y: int
|
||||
|
||||
@staticmethod
|
||||
def random() -> 'Vector':
|
||||
return Vector(randrange(-1, 2, 2), randrange(-1, 2, 2))
|
||||
|
||||
def __mul__(self, factor: int) -> 'Vector':
|
||||
return Vector(self.x * factor, self.y * factor)
|
||||
|
||||
|
||||
class Sea:
|
||||
WIDTH = 6
|
||||
|
||||
def __init__(self):
|
||||
self._graph = tuple(([0 for _ in range(self.WIDTH)] for _ in range(self.WIDTH)))
|
||||
|
||||
def _validate_item_indices(self, point: Point) -> None:
|
||||
if not isinstance(point, Point):
|
||||
raise ValueError(f'Sea indices must be Points, not {type(point).__name__}')
|
||||
|
||||
if not((1 <= point.x <= self.WIDTH) and (1 <= point.y <= self.WIDTH)):
|
||||
raise IndexError('Sea index out of range')
|
||||
|
||||
# Allows us to get the value using a point as a key, for example, `sea[Point(3,2)]`
|
||||
def __getitem__(self, point: Point) -> int:
|
||||
self._validate_item_indices(point)
|
||||
|
||||
return self._graph[point.y - 1][point.x -1]
|
||||
|
||||
# Allows us to get the value using a point as a key, for example, `sea[Point(3,2)] = 3`
|
||||
def __setitem__(self, point: Point, value: int) -> None:
|
||||
self._validate_item_indices(point)
|
||||
self._graph[point.y - 1][point.x -1] = value
|
||||
|
||||
# Allows us to check if a point exists in the sea for example, `if Point(3,2) in sea:`
|
||||
def __contains__(self, point: Point) -> bool:
|
||||
try:
|
||||
self._validate_item_indices(point)
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# Redefines how python will render this object when asked as a str
|
||||
def __str__(self):
|
||||
# Display it encoded
|
||||
return "\n".join([' '.join([str(self._graph[y][x])
|
||||
for y in range(self.WIDTH - 1, -1, -1)])
|
||||
for x in range(self.WIDTH)])
|
||||
|
||||
def has_ship(self, ship_code: int) -> bool:
|
||||
return any(ship_code in row for row in self._graph)
|
||||
|
||||
def count_sunk(self, *ship_codes: int) -> int:
|
||||
return sum(not self.has_ship(ship_code) for ship_code in ship_codes)
|
||||
|
||||
|
||||
class Battle:
|
||||
def __init__(self) -> None:
|
||||
self.sea = Sea()
|
||||
self.place_ship(DESTROYER_LENGTH, 1)
|
||||
self.place_ship(DESTROYER_LENGTH, 2)
|
||||
self.place_ship(CRUISER_LENGTH, 3)
|
||||
self.place_ship(CRUISER_LENGTH, 4)
|
||||
self.place_ship(AIRCRAFT_CARRIER_LENGTH, 5)
|
||||
self.place_ship(AIRCRAFT_CARRIER_LENGTH, 6)
|
||||
self.splashes = 0
|
||||
self.hits = 0
|
||||
|
||||
def _next_target(self) -> Point:
|
||||
while True:
|
||||
try:
|
||||
guess = input('? ')
|
||||
coordinates = guess.split(',')
|
||||
|
||||
if len(coordinates) != 2:
|
||||
raise ValueError()
|
||||
|
||||
point = Point(int(coordinates[0]), int(coordinates[1]))
|
||||
|
||||
if point not in self.sea:
|
||||
raise ValueError()
|
||||
|
||||
return point
|
||||
except ValueError:
|
||||
print(f'INVALID. SPECIFY TWO NUMBERS FROM 1 TO {Sea.WIDTH}, SEPARATED BY A COMMA.')
|
||||
|
||||
@property
|
||||
def splash_hit_ratio(self) -> str:
|
||||
return f'{self.splashes}/{self.hits}'
|
||||
|
||||
@property
|
||||
def _is_finished(self) -> bool:
|
||||
return self.sea.count_sunk(*(i for i in range(1, 7))) == 6
|
||||
|
||||
def place_ship(self, size: int, ship_code: int) -> None:
|
||||
while True:
|
||||
start = Point.random(1, self.sea.WIDTH + 1)
|
||||
vector = Vector.random()
|
||||
# Get potential ship points
|
||||
points = [start + vector * i for i in range(size)]
|
||||
|
||||
if not (all([point in self.sea for point in points]) and
|
||||
not any([self.sea[point] for point in points])):
|
||||
# ship out of bounds or crosses other ship, trying again
|
||||
continue
|
||||
|
||||
# We found a valid spot, so actually place it now
|
||||
for point in points:
|
||||
self.sea[point] = ship_code
|
||||
|
||||
break
|
||||
|
||||
|
||||
def loop(self):
|
||||
while True:
|
||||
target = self._next_target()
|
||||
target_value = self.sea[target]
|
||||
|
||||
if target_value < 0:
|
||||
print(f'YOU ALREADY PUT A HOLE IN SHIP NUMBER {abs(target_value)} AT THAT POINT.')
|
||||
|
||||
if target_value <= 0:
|
||||
print('SPLASH! TRY AGAIN.')
|
||||
self.splashes += 1
|
||||
continue
|
||||
|
||||
print(f'A DIRECT HIT ON SHIP NUMBER {target_value}')
|
||||
self.hits += 1
|
||||
self.sea[target] = -target_value
|
||||
|
||||
if not self.sea.has_ship(target_value):
|
||||
print('AND YOU SUNK IT. HURRAH FOR THE GOOD GUYS.')
|
||||
self._display_sunk_report()
|
||||
|
||||
if self._is_finished:
|
||||
self._display_game_end()
|
||||
break
|
||||
|
||||
print(f'YOUR CURRENT SPLASH/HIT RATIO IS {self.splash_hit_ratio}')
|
||||
|
||||
def _display_sunk_report(self):
|
||||
print('SO FAR, THE BAD GUYS HAVE LOST',
|
||||
f'{self.sea.count_sunk(1, 2)} DESTROYER(S),',
|
||||
f'{self.sea.count_sunk(3, 4)} CRUISER(S),',
|
||||
f'AND {self.sea.count_sunk(5, 6)} AIRCRAFT CARRIER(S).')
|
||||
|
||||
def _display_game_end(self):
|
||||
print('YOU HAVE TOTALLY WIPED OUT THE BAD GUYS\' FLEET '
|
||||
f'WITH A FINAL SPLASH/HIT RATIO OF {self.splash_hit_ratio}')
|
||||
|
||||
if not self.splashes:
|
||||
print('CONGRATULATIONS -- A DIRECT HIT EVERY TIME.')
|
||||
|
||||
print("\n****************************")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
game = Battle()
|
||||
print(f'''
|
||||
BATTLE
|
||||
CREATIVE COMPUTING MORRISTOWN, NEW JERSEY
|
||||
|
||||
THE FOLLOWING CODE OF THE BAD GUYS' FLEET DISPOSITION
|
||||
HAS BEEN CAPTURED BUT NOT DECODED:
|
||||
|
||||
{game.sea}
|
||||
|
||||
DE-CODE IT AND USE IT IF YOU CAN
|
||||
BUT KEEP THE DE-CODING METHOD A SECRET.
|
||||
|
||||
START GAME''')
|
||||
game.loop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
22
09_Battle/vbnet/Battle.sln
Normal file
22
09_Battle/vbnet/Battle.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Battle", "Battle.vbproj", "{D8475464-CB9B-448F-89A7-5BA15193C495}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D8475464-CB9B-448F-89A7-5BA15193C495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8475464-CB9B-448F-89A7-5BA15193C495}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8475464-CB9B-448F-89A7-5BA15193C495}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8475464-CB9B-448F-89A7-5BA15193C495}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
09_Battle/vbnet/Battle.vbproj
Normal file
8
09_Battle/vbnet/Battle.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Battle</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
10_Blackjack/csharp/Blackjack.sln
Normal file
22
10_Blackjack/csharp/Blackjack.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blackjack", "Blackjack.csproj", "{83253F48-9CCD-475C-A990-8703F1A2E31C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{83253F48-9CCD-475C-A990-8703F1A2E31C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{83253F48-9CCD-475C-A990-8703F1A2E31C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{83253F48-9CCD-475C-A990-8703F1A2E31C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{83253F48-9CCD-475C-A990-8703F1A2E31C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
10_Blackjack/vbnet/Blackjack.sln
Normal file
22
10_Blackjack/vbnet/Blackjack.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Blackjack", "Blackjack.vbproj", "{B112CA5F-142B-46E9-92CB-5E3A84816AAE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B112CA5F-142B-46E9-92CB-5E3A84816AAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B112CA5F-142B-46E9-92CB-5E3A84816AAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B112CA5F-142B-46E9-92CB-5E3A84816AAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B112CA5F-142B-46E9-92CB-5E3A84816AAE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
10_Blackjack/vbnet/Blackjack.vbproj
Normal file
8
10_Blackjack/vbnet/Blackjack.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Blackjack</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
11_Bombardment/csharp/Bombardment.sln
Normal file
22
11_Bombardment/csharp/Bombardment.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bombardment", "Bombardment.csproj", "{1DCFD283-9300-405B-A2B4-231F30265730}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1DCFD283-9300-405B-A2B4-231F30265730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1DCFD283-9300-405B-A2B4-231F30265730}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1DCFD283-9300-405B-A2B4-231F30265730}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1DCFD283-9300-405B-A2B4-231F30265730}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
11_Bombardment/vbnet/Bombardment.sln
Normal file
22
11_Bombardment/vbnet/Bombardment.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bombardment", "Bombardment.vbproj", "{7C967BC0-101C-413F-92A8-3A8A7D9846FE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7C967BC0-101C-413F-92A8-3A8A7D9846FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7C967BC0-101C-413F-92A8-3A8A7D9846FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7C967BC0-101C-413F-92A8-3A8A7D9846FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7C967BC0-101C-413F-92A8-3A8A7D9846FE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
11_Bombardment/vbnet/Bombardment.vbproj
Normal file
8
11_Bombardment/vbnet/Bombardment.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bombardment</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
12_Bombs_Away/vbnet/BombsAway.sln
Normal file
22
12_Bombs_Away/vbnet/BombsAway.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BombsAway", "BombsAway.vbproj", "{7FB28848-EC1C-4594-B823-BA6DB06B34A8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7FB28848-EC1C-4594-B823-BA6DB06B34A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7FB28848-EC1C-4594-B823-BA6DB06B34A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7FB28848-EC1C-4594-B823-BA6DB06B34A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7FB28848-EC1C-4594-B823-BA6DB06B34A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
12_Bombs_Away/vbnet/BombsAway.vbproj
Normal file
8
12_Bombs_Away/vbnet/BombsAway.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>BombsAway</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
9
13_Bounce/csharp/Bounce.csproj
Normal file
9
13_Bounce/csharp/Bounce.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
13_Bounce/csharp/Bounce.sln
Normal file
22
13_Bounce/csharp/Bounce.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bounce", "Bounce.csproj", "{4A967985-8CB0-49D2-B322-B2668491CA6E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4A967985-8CB0-49D2-B322-B2668491CA6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A967985-8CB0-49D2-B322-B2668491CA6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A967985-8CB0-49D2-B322-B2668491CA6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A967985-8CB0-49D2-B322-B2668491CA6E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
13_Bounce/vbnet/Bounce.sln
Normal file
22
13_Bounce/vbnet/Bounce.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bounce", "Bounce.vbproj", "{95D84C53-AE4E-4A5A-869A-A49D6FC89618}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{95D84C53-AE4E-4A5A-869A-A49D6FC89618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{95D84C53-AE4E-4A5A-869A-A49D6FC89618}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{95D84C53-AE4E-4A5A-869A-A49D6FC89618}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{95D84C53-AE4E-4A5A-869A-A49D6FC89618}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
13_Bounce/vbnet/Bounce.vbproj
Normal file
8
13_Bounce/vbnet/Bounce.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bounce</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
9
14_Bowling/csharp/Bowling.csproj
Normal file
9
14_Bowling/csharp/Bowling.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
14_Bowling/csharp/Bowling.sln
Normal file
22
14_Bowling/csharp/Bowling.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bowling", "Bowling.csproj", "{9951637A-8D70-42A4-8CB7-315FA414F960}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9951637A-8D70-42A4-8CB7-315FA414F960}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9951637A-8D70-42A4-8CB7-315FA414F960}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9951637A-8D70-42A4-8CB7-315FA414F960}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9951637A-8D70-42A4-8CB7-315FA414F960}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
14_Bowling/vbnet/Bowling.sln
Normal file
22
14_Bowling/vbnet/Bowling.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bowling", "Bowling.vbproj", "{DBEB424A-1538-4F14-BA57-BA4E326EF4D8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DBEB424A-1538-4F14-BA57-BA4E326EF4D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DBEB424A-1538-4F14-BA57-BA4E326EF4D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DBEB424A-1538-4F14-BA57-BA4E326EF4D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DBEB424A-1538-4F14-BA57-BA4E326EF4D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
14_Bowling/vbnet/Bowling.vbproj
Normal file
8
14_Bowling/vbnet/Bowling.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bowling</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
15_Boxing/vbnet/Boxing.sln
Normal file
22
15_Boxing/vbnet/Boxing.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Boxing", "Boxing.vbproj", "{8BCEDE01-59A7-4AA3-AE09-8B7FD69A5867}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8BCEDE01-59A7-4AA3-AE09-8B7FD69A5867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8BCEDE01-59A7-4AA3-AE09-8B7FD69A5867}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8BCEDE01-59A7-4AA3-AE09-8B7FD69A5867}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8BCEDE01-59A7-4AA3-AE09-8B7FD69A5867}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
15_Boxing/vbnet/Boxing.vbproj
Normal file
8
15_Boxing/vbnet/Boxing.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Boxing</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
9
16_Bug/csharp/Bug.csproj
Normal file
9
16_Bug/csharp/Bug.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
16_Bug/csharp/Bug.sln
Normal file
22
16_Bug/csharp/Bug.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bug", "Bug.csproj", "{C1929CC1-C366-43E4-9476-AE107231A302}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C1929CC1-C366-43E4-9476-AE107231A302}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C1929CC1-C366-43E4-9476-AE107231A302}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C1929CC1-C366-43E4-9476-AE107231A302}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C1929CC1-C366-43E4-9476-AE107231A302}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
16_Bug/vbnet/Bug.sln
Normal file
22
16_Bug/vbnet/Bug.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bug", "Bug.vbproj", "{4F4EA8E5-55A8-4191-BE57-B28638C33609}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4F4EA8E5-55A8-4191-BE57-B28638C33609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F4EA8E5-55A8-4191-BE57-B28638C33609}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F4EA8E5-55A8-4191-BE57-B28638C33609}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F4EA8E5-55A8-4191-BE57-B28638C33609}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,9 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>AceyDucy</RootNamespace>
|
||||
<RootNamespace>Bug</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31321.278
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Game", "Game.csproj", "{8F7C450E-5F3A-45BA-9DB9-329744214931}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bullfight", "Bullfight.csproj", "{502A672C-F7D7-4A85-973A-B5EA8761008A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -11,10 +11,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8F7C450E-5F3A-45BA-9DB9-329744214931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8F7C450E-5F3A-45BA-9DB9-329744214931}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8F7C450E-5F3A-45BA-9DB9-329744214931}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8F7C450E-5F3A-45BA-9DB9-329744214931}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{502A672C-F7D7-4A85-973A-B5EA8761008A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{502A672C-F7D7-4A85-973A-B5EA8761008A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{502A672C-F7D7-4A85-973A-B5EA8761008A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{502A672C-F7D7-4A85-973A-B5EA8761008A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
22
17_Bullfight/vbnet/Bullfight.sln
Normal file
22
17_Bullfight/vbnet/Bullfight.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bullfight", "Bullfight.vbproj", "{38805A6B-C251-4C45-9832-B8E2F3F6436F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{38805A6B-C251-4C45-9832-B8E2F3F6436F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{38805A6B-C251-4C45-9832-B8E2F3F6436F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{38805A6B-C251-4C45-9832-B8E2F3F6436F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{38805A6B-C251-4C45-9832-B8E2F3F6436F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
17_Bullfight/vbnet/Bullfight.vbproj
Normal file
8
17_Bullfight/vbnet/Bullfight.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bullfight</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
18_Bullseye/vbnet/Bullseye.sln
Normal file
22
18_Bullseye/vbnet/Bullseye.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bullseye", "Bullseye.vbproj", "{0CFD308F-EB9C-4A05-B742-5EE7C912A5E4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0CFD308F-EB9C-4A05-B742-5EE7C912A5E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0CFD308F-EB9C-4A05-B742-5EE7C912A5E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0CFD308F-EB9C-4A05-B742-5EE7C912A5E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0CFD308F-EB9C-4A05-B742-5EE7C912A5E4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
18_Bullseye/vbnet/Bullseye.vbproj
Normal file
8
18_Bullseye/vbnet/Bullseye.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bullseye</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
9
19_Bunny/csharp/Bunny.csproj
Normal file
9
19_Bunny/csharp/Bunny.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
19_Bunny/csharp/Bunny.sln
Normal file
22
19_Bunny/csharp/Bunny.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bunny", "Bunny.csproj", "{6685F5CF-20F2-4682-B187-50105BD44906}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6685F5CF-20F2-4682-B187-50105BD44906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6685F5CF-20F2-4682-B187-50105BD44906}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6685F5CF-20F2-4682-B187-50105BD44906}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6685F5CF-20F2-4682-B187-50105BD44906}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
22
19_Bunny/vbnet/Bunny.sln
Normal file
22
19_Bunny/vbnet/Bunny.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Bunny", "Bunny.vbproj", "{E9098ADF-4B31-4082-9102-2A5BB8B40C6C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E9098ADF-4B31-4082-9102-2A5BB8B40C6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9098ADF-4B31-4082-9102-2A5BB8B40C6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9098ADF-4B31-4082-9102-2A5BB8B40C6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9098ADF-4B31-4082-9102-2A5BB8B40C6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
19_Bunny/vbnet/Bunny.vbproj
Normal file
8
19_Bunny/vbnet/Bunny.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bunny</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
20_Buzzword/vbnet/Buzzword.sln
Normal file
22
20_Buzzword/vbnet/Buzzword.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Buzzword", "Buzzword.vbproj", "{B2BD53F2-82C3-4729-BA82-DB96E18F8666}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B2BD53F2-82C3-4729-BA82-DB96E18F8666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B2BD53F2-82C3-4729-BA82-DB96E18F8666}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B2BD53F2-82C3-4729-BA82-DB96E18F8666}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B2BD53F2-82C3-4729-BA82-DB96E18F8666}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
20_Buzzword/vbnet/Buzzword.vbproj
Normal file
8
20_Buzzword/vbnet/Buzzword.vbproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Buzzword</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>16.9</LangVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user