mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-05 17:48:52 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
7
63_Name/README.md
Normal file
7
63_Name/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Name
|
||||
|
||||
As published in Basic Computer Games (1978)
|
||||
https://www.atariarchives.org/basicgames/showpage.php?page=116
|
||||
|
||||
Downloaded from Vintage Basic at
|
||||
http://www.vintage-basic.net/games.html
|
||||
8
63_Name/csharp/Name.csproj
Normal file
8
63_Name/csharp/Name.csproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
25
63_Name/csharp/Name.sln
Normal file
25
63_Name/csharp/Name.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31005.135
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Name", "Name.csproj", "{B63B5D5C-C5E0-4EFE-9EF4-292915DCC22D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B63B5D5C-C5E0-4EFE-9EF4-292915DCC22D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B63B5D5C-C5E0-4EFE-9EF4-292915DCC22D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B63B5D5C-C5E0-4EFE-9EF4-292915DCC22D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B63B5D5C-C5E0-4EFE-9EF4-292915DCC22D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {FCD5BEAE-D35E-49A7-B8F3-B8B3F4A8C624}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
44
63_Name/csharp/Program.cs
Normal file
44
63_Name/csharp/Program.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
|
||||
namespace Name
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("NAME".CentreAlign());
|
||||
Console.WriteLine("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY".CentreAlign());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("HELLO.");
|
||||
Console.WriteLine("MY NAME IS CREATIVE COMPUTER.");
|
||||
Console.Write("WHAT'S YOUR NAME (FIRST AND LAST? ");
|
||||
var name = Console.ReadLine();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"THANK YOU, {name.Reverse()}.");
|
||||
Console.WriteLine("OOPS! I GUESS I GOT IT BACKWARDS. A SMART");
|
||||
Console.WriteLine("COMPUTER LIKE ME SHOULDN'T MAKE A MISTAKE LIKE THAT!");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("BUT I JUST NOTICED YOUR LETTERS ARE OUT OF ORDER.");
|
||||
Console.WriteLine($"LET'S PUT THEM IN ORDER LIKE THIS: {name.Sort()}");
|
||||
Console.WriteLine();
|
||||
Console.Write("DON'T YOU LIKE THAT BETTER? ");
|
||||
var like = Console.ReadLine();
|
||||
Console.WriteLine();
|
||||
|
||||
if (like.ToUpperInvariant() == "YES")
|
||||
{
|
||||
Console.WriteLine("I KNEW YOU'D AGREE!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("I'M SORRY YOU DON'T LIKE IT THAT WAY.");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"I REALLY ENJOYED MEETING YOU {name}.");
|
||||
Console.WriteLine("HAVE A NICE DAY!");
|
||||
}
|
||||
}
|
||||
}
|
||||
3
63_Name/csharp/README.md
Normal file
3
63_Name/csharp/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Microsoft C#](https://docs.microsoft.com/en-us/dotnet/csharp/)
|
||||
41
63_Name/csharp/StringExtensions.cs
Normal file
41
63_Name/csharp/StringExtensions.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace Name
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
private const int ConsoleWidth = 120; // default console width
|
||||
|
||||
public static string CentreAlign(this string value)
|
||||
{
|
||||
int spaces = ConsoleWidth - value.Length;
|
||||
int leftPadding = spaces / 2 + value.Length;
|
||||
|
||||
return value.PadLeft(leftPadding).PadRight(ConsoleWidth);
|
||||
}
|
||||
|
||||
public static string Reverse(this string value)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
char[] characterArray = value.ToCharArray();
|
||||
Array.Reverse(characterArray);
|
||||
return new String(characterArray);
|
||||
}
|
||||
|
||||
public static string Sort(this string value)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
char[] characters = value.ToCharArray();
|
||||
Array.Sort(characters);
|
||||
return new string(characters);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
63_Name/java/README.md
Normal file
3
63_Name/java/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Oracle Java](https://openjdk.java.net/)
|
||||
55
63_Name/java/main.class
Normal file
55
63_Name/java/main.class
Normal file
@@ -0,0 +1,55 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class main {
|
||||
|
||||
public static void printempty() { System.out.println(" "); }
|
||||
|
||||
public static void print(String toprint) { System.out.println(toprint); }
|
||||
|
||||
public static void main(String[] args) {
|
||||
print(" NAME");
|
||||
print(" CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
|
||||
printempty();
|
||||
printempty();
|
||||
print("HELLO.");
|
||||
print("MY NAME iS CREATIVE COMPUTER.");
|
||||
print("WHATS YOUR NAME? (FIRST AND LAST)");
|
||||
|
||||
Scanner namesc = new Scanner(System.in);
|
||||
String name = namesc.nextLine();
|
||||
|
||||
String namereversed = new StringBuilder(name).reverse().toString();
|
||||
|
||||
char namesorted[] = name.toCharArray();
|
||||
Arrays.sort(namesorted);
|
||||
|
||||
printempty();
|
||||
print("THANK YOU, " + namereversed);
|
||||
printempty();
|
||||
print("OOPS! I GUESS I GOT IT BACKWARDS. A SMART");
|
||||
print("COMPUTER LIKE ME SHOULDN'T MAKE A MISTAKE LIKE THAT!");
|
||||
printempty();
|
||||
printempty();
|
||||
print("BUT I JUST NOTICED YOUR LETTERS ARE OUT OF ORDER.");
|
||||
|
||||
print("LET'S PUT THEM IN ORDER LIKE THIS: " + new String(namesorted));
|
||||
printempty();
|
||||
printempty();
|
||||
|
||||
print("DON'T YOU LIKE THAT BETTER?");
|
||||
printempty();
|
||||
|
||||
Scanner agreementsc = new Scanner(System.in);
|
||||
String agreement = agreementsc.nextLine();
|
||||
|
||||
if (agreement.equalsIgnoreCase("yes")) {
|
||||
print("I KNEW YOU'D AGREE!!");
|
||||
} else {
|
||||
print("I'M SORRY YOU DON'T LIKE IT THAT WAY.");
|
||||
printempty();
|
||||
print("I REALLY ENJOYED MEETING YOU, " + name);
|
||||
print("HAVE A NICE DAY!");
|
||||
}
|
||||
}
|
||||
}
|
||||
3
63_Name/javascript/README.md
Normal file
3
63_Name/javascript/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shells)
|
||||
9
63_Name/javascript/name.html
Normal file
9
63_Name/javascript/name.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>NAME</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="name.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
93
63_Name/javascript/name.js
Normal file
93
63_Name/javascript/name.js
Normal file
@@ -0,0 +1,93 @@
|
||||
// NAME
|
||||
//
|
||||
// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
|
||||
//
|
||||
|
||||
function print(str)
|
||||
{
|
||||
document.getElementById("output").appendChild(document.createTextNode(str));
|
||||
}
|
||||
|
||||
function input()
|
||||
{
|
||||
var input_element;
|
||||
var input_str;
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
input_element = document.createElement("INPUT");
|
||||
|
||||
print("? ");
|
||||
input_element.setAttribute("type", "text");
|
||||
input_element.setAttribute("length", "50");
|
||||
document.getElementById("output").appendChild(input_element);
|
||||
input_element.focus();
|
||||
input_str = undefined;
|
||||
input_element.addEventListener("keydown", function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
input_str = input_element.value;
|
||||
document.getElementById("output").removeChild(input_element);
|
||||
print(input_str);
|
||||
print("\n");
|
||||
resolve(input_str);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tab(space)
|
||||
{
|
||||
var str = "";
|
||||
while (space-- > 0)
|
||||
str += " ";
|
||||
return str;
|
||||
}
|
||||
|
||||
var str;
|
||||
var b;
|
||||
|
||||
// Main program
|
||||
async function main()
|
||||
{
|
||||
print(tab(34) + "NAME\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("HELLO.\n");
|
||||
print("MY NAME IS CREATIVE COMPUTER.\n");
|
||||
print("WHAT'S YOUR NAME (FIRST AND LAST)");
|
||||
str = await input();
|
||||
l = str.length;
|
||||
print("\n");
|
||||
print("THANK YOU, ");
|
||||
for (i = l; i >= 1; i--)
|
||||
print(str[i - 1]);
|
||||
print(".\n");
|
||||
print("OOPS! I GUESS I GOT IT BACKWARDS. A SMART\n");
|
||||
print("COMPUTER LIKE ME SHOULDN'T MAKE A MISTAKE LIKE THAT!\n");
|
||||
print("\n");
|
||||
print("BUT I JUST NOTICED YOUR LETTERS ARE OUT OF ORDER.\n");
|
||||
print("LET'S PUT THEM IN ORDER LIKE THIS: ");
|
||||
b = [];
|
||||
for (i = 1; i <= l; i++)
|
||||
b[i - 1] = str.charCodeAt(i - 1);
|
||||
b.sort();
|
||||
for (i = 1; i <= l; i++)
|
||||
print(String.fromCharCode(b[i - 1]));
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("DON'T YOU LIKE THAT BETTER");
|
||||
ds = await input();
|
||||
if (ds == "YES") {
|
||||
print("\n");
|
||||
print("I KNEW YOU'D AGREE!!\n");
|
||||
} else {
|
||||
print("\n");
|
||||
print("I'M SORRY YOU DON'T LIKE IT THAT WAY.\n");
|
||||
}
|
||||
print("\n");
|
||||
print("I REALLY ENJOYED MEETING YOU " + str + ".\n");
|
||||
print("HAVE A NICE DAY!\n");
|
||||
}
|
||||
|
||||
main();
|
||||
25
63_Name/name.bas
Normal file
25
63_Name/name.bas
Normal file
@@ -0,0 +1,25 @@
|
||||
1 PRINT TAB(34);"NAME"
|
||||
2 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
3 PRINT: PRINT: PRINT
|
||||
5 DIM B$(40)
|
||||
10 PRINT "HELLO.": PRINT "MY NAME IS CREATIVE COMPUTER."
|
||||
20 PRINT "WHAT'S YOUR NAME (FIRST AND LAST";: INPUT A$: L=LEN(A$)
|
||||
30 PRINT: PRINT "THANK YOU, ";
|
||||
40 FOR I=1 TO L: B$(I)=MID$(A$,I,1): NEXT I
|
||||
50 FOR I=L TO 1 STEP -1: PRINT B$(I);: NEXT I
|
||||
60 PRINT ".": PRINT "OOPS! I GUESS I GOT IT BACKWARDS. A SMART"
|
||||
70 PRINT "COMPUTER LIKE ME SHOULDN'T MAKE A MISTAKE LIKE THAT!": PRINT
|
||||
80 PRINT "BUT I JUST NOTICED YOUR LETTERS ARE OUT OF ORDER."
|
||||
90 PRINT "LET'S PUT THEM IN ORDER LIKE THIS: ";
|
||||
100 FOR J=2 TO L: I=J-1: T$=B$(J)
|
||||
110 IF T$>B$(I) THEN 130
|
||||
120 B$(I+1)=B$(I): I=I-1: IF I>0 THEN 110
|
||||
130 B$(I+1)=T$: NEXT J
|
||||
140 FOR I=1 TO L: PRINT B$(I);: NEXT I: PRINT: PRINT
|
||||
150 PRINT "DON'T YOU LIKE THAT BETTER";: INPUT D$
|
||||
160 IF D$="YES" THEN 180
|
||||
170 PRINT: PRINT "I'M SORRY YOU DON'T LIKE IT THAT WAY.": GOTO 200
|
||||
180 PRINT: PRINT "I KNEW YOU'D AGREE!!"
|
||||
200 PRINT: PRINT "I REALLY ENJOYED MEETING YOU ";A$;"."
|
||||
210 PRINT "HAVE A NICE DAY!"
|
||||
999 END
|
||||
3
63_Name/pascal/README.md
Normal file
3
63_Name/pascal/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))
|
||||
3
63_Name/perl/README.md
Normal file
3
63_Name/perl/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Perl](https://www.perl.org/)
|
||||
35
63_Name/perl/name.pl
Executable file
35
63_Name/perl/name.pl
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/perl
|
||||
use strict;
|
||||
|
||||
print ' 'x34 . "NAME\n";
|
||||
print ' 'x15 . "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n";
|
||||
print "\n\n\n";
|
||||
|
||||
print "HELLO.\n"; print "MY NAME IS CREATIVE COMPUTER.\n";
|
||||
print "WHAT'S YOUR NAME (FIRST AND LAST): ";
|
||||
chomp (my $A = <STDIN>);
|
||||
|
||||
my @B= split("", $A); #Convert string to array of characters.
|
||||
|
||||
print "\n"; print "THANK YOU, ";
|
||||
print reverse @B;
|
||||
|
||||
print ".\n"; print "OOPS! I GUESS I GOT IT BACKWARDS. A SMART\n";
|
||||
print "COMPUTER LIKE ME SHOULDN'T MAKE A MISTAKE LIKE THAT!\n\n";
|
||||
print "BUT I JUST NOTICED YOUR LETTERS ARE OUT OF ORDER.\n";
|
||||
print "LET'S PUT THEM IN ORDER LIKE THIS: ";
|
||||
print sort @B;
|
||||
|
||||
print "\n\n";
|
||||
print "DON'T YOU LIKE THAT BETTER? ";
|
||||
chomp (my $D = <STDIN>);
|
||||
if (uc($D) eq "YES") {
|
||||
print "\n"; print "I KNEW YOU'D AGREE!!\n";
|
||||
} else {
|
||||
print "\n"; print "I'M SORRY YOU DON'T LIKE IT THAT WAY.\n";
|
||||
}
|
||||
print "\n"; print "I REALLY ENJOYED MEETING YOU $A.\n";
|
||||
print "HAVE A NICE DAY!\n";
|
||||
exit;
|
||||
|
||||
|
||||
3
63_Name/python/README.md
Normal file
3
63_Name/python/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Python](https://www.python.org/about/)
|
||||
62
63_Name/python/name.py
Normal file
62
63_Name/python/name.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
NAME
|
||||
|
||||
simple string manipulations on the user's name
|
||||
|
||||
Ported by Dave LeCompte
|
||||
"""
|
||||
|
||||
|
||||
def print_with_tab(space_count, msg):
|
||||
if space_count > 0:
|
||||
spaces = " " * space_count
|
||||
else:
|
||||
spaces = ""
|
||||
print(spaces + msg)
|
||||
|
||||
|
||||
def is_yes_ish(answer):
|
||||
cleaned = answer.strip().upper()
|
||||
if cleaned == "Y" or cleaned == "YES":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
print_with_tab(34, "NAME")
|
||||
print_with_tab(15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
print()
|
||||
print()
|
||||
print()
|
||||
print("HELLO.")
|
||||
print("MY NAME iS CREATIVE COMPUTER.")
|
||||
name = input("WHAT'S YOUR NAME (FIRST AND LAST)?")
|
||||
print()
|
||||
name_as_list = list(name)
|
||||
reversed_name = "".join(name_as_list[::-1])
|
||||
print(f"THANK YOU, {reversed_name}.")
|
||||
print()
|
||||
print("OOPS! I GUESS I GOT IT BACKWARDS. A SMART")
|
||||
print("COMPUTER LIKE ME SHOULDN'T MAKE A MISTAKE LIKE THAT!")
|
||||
print()
|
||||
print()
|
||||
print("BUT I JUST NOTICED YOUR LETTERS ARE OUT OF ORDER.")
|
||||
|
||||
sorted_name = "".join(sorted(name_as_list))
|
||||
print(f"LET'S PUT THEM IN ORDER LIKE THIS: {sorted_name}")
|
||||
print()
|
||||
print()
|
||||
|
||||
print("DON'T YOU LIKE THAT BETTER?")
|
||||
like_answer = input()
|
||||
print()
|
||||
if is_yes_ish(like_answer):
|
||||
print("I KNEW YOU'D AGREE!!")
|
||||
else:
|
||||
print("I'M SORRY YOU DON'T LIKE IT THAT WAY.")
|
||||
print()
|
||||
print(f"I REALLY ENJOYED MEETING YOU, {name}.")
|
||||
print("HAVE A NICE DAY!")
|
||||
|
||||
|
||||
main()
|
||||
3
63_Name/ruby/README.md
Normal file
3
63_Name/ruby/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Ruby](https://www.ruby-lang.org/en/)
|
||||
3
63_Name/vbnet/README.md
Normal file
3
63_Name/vbnet/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original BASIC source [downloaded from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Visual Basic .NET](https://en.wikipedia.org/wiki/Visual_Basic_.NET)
|
||||
Reference in New Issue
Block a user