mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-01 15:49:59 -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
45_Hello/README.md
Normal file
7
45_Hello/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Hello
|
||||
|
||||
As published in Basic Computer Games (1978)
|
||||
https://www.atariarchives.org/basicgames/showpage.php?page=82
|
||||
|
||||
Downloaded from Vintage Basic at
|
||||
http://www.vintage-basic.net/games.html
|
||||
3
45_Hello/csharp/README.md
Normal file
3
45_Hello/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/)
|
||||
83
45_Hello/hello.bas
Normal file
83
45_Hello/hello.bas
Normal file
@@ -0,0 +1,83 @@
|
||||
2 PRINT TAB(33);"HELLO"
|
||||
4 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
6 PRINT: PRINT: PRINT
|
||||
10 PRINT "HELLO. MY NAME IS CREATIVE COMPUTER."
|
||||
20 PRINT: PRINT: INPUT "WHAT'S YOUR NAME";N$: PRINT
|
||||
30 PRINT "HI THERE, ";N$;", ARE YOU ENJOYING YOURSELF HERE";
|
||||
40 INPUT B$: PRINT
|
||||
50 IF B$="YES" THEN 70
|
||||
55 IF B$="NO" THEN 80
|
||||
60 PRINT N$;", I DON'T UNDERSTAND YOUR ANSWER OF '";B$;"'."
|
||||
65 PRINT "PLEASE ANSWER 'YES' OR 'NO'. DO YOU LIKE IT HERE";: GOTO 40
|
||||
70 PRINT "I'M GLAD TO HEAR THAT, ";N$;".": PRINT
|
||||
75 GOTO 100
|
||||
80 PRINT "OH, I'M SORRY TO HEAR THAT, ";N$;". MAYBE WE CAN"
|
||||
85 PRINT "BRIGHTEN UP YOUR VISIT A BIT."
|
||||
100 PRINT
|
||||
105 PRINT "SAY, ";N$;", I CAN SOLVE ALL KINDS OF PROBLEMS EXCEPT"
|
||||
110 PRINT "THOSE DEALING WITH GREECE. WHAT KIND OF PROBLEMS DO"
|
||||
120 PRINT "YOU HAVE (ANSWER SEX, HEALTH, MONEY, OR JOB)";
|
||||
125 INPUT C$
|
||||
126 PRINT
|
||||
130 IF C$="SEX" THEN 200
|
||||
132 IF C$="HEALTH" THEN 180
|
||||
134 IF C$="MONEY" THEN 160
|
||||
136 IF C$="JOB" THEN 145
|
||||
138 PRINT "OH, ";N$;", YOUR ANSWER OF ";C$;" IS GREEK TO ME."
|
||||
140 GOTO 250
|
||||
145 PRINT "I CAN SYMPATHIZE WITH YOU ";N$;". I HAVE TO WORK"
|
||||
148 PRINT "VERY LONG HOURS FOR NO PAY -- AND SOME OF MY BOSSES"
|
||||
150 PRINT "REALLY BEAT ON MY KEYBOARD. MY ADVICE TO YOU, ";N$;","
|
||||
153 PRINT "IS TO OPEN A RETAIL COMPUTER STORE. IT'S GREAT FUN."
|
||||
155 GOTO 250
|
||||
160 PRINT "SORRY, ";N$;", I'M BROKE TOO. WHY DON'T YOU SELL"
|
||||
162 PRINT "ENCYCLOPEADIAS OR MARRY SOMEONE RICH OR STOP EATING"
|
||||
164 PRINT "SO YOU WON'T NEED SO MUCH MONEY?"
|
||||
170 GOTO 250
|
||||
180 PRINT "MY ADVICE TO YOU ";N$;" IS:"
|
||||
185 PRINT " 1. TAKE TWO ASPRIN"
|
||||
188 PRINT " 2. DRINK PLENTY OF FLUIDS (ORANGE JUICE, NOT BEER!)"
|
||||
190 PRINT " 3. GO TO BED (ALONE)"
|
||||
195 GOTO 250
|
||||
200 INPUT "IS YOUR PROBLEM TOO MUCH OR TOO LITTLE";D$: PRINT
|
||||
210 IF D$="TOO MUCH" THEN 220
|
||||
212 IF D$="TOO LITTLE" THEN 230
|
||||
215 PRINT "DON'T GET ALL SHOOK, ";N$;", JUST ANSWER THE QUESTION"
|
||||
217 INPUT "WITH 'TOO MUCH' OR 'TOO LITTLE'. WHICH IS IT";D$:GOTO 210
|
||||
220 PRINT "YOU CALL THAT A PROBLEM?!! I SHOULD HAVE SUCH PROBLEMS!"
|
||||
225 PRINT "IF IT BOTHERS YOU, ";N$;", TAKE A COLD SHOWER."
|
||||
228 GOTO 250
|
||||
230 PRINT "WHY ARE YOU HERE IN SUFFERN, ";N$;"? YOU SHOULD BE"
|
||||
235 PRINT "IN TOKYO OR NEW YORK OR AMSTERDAM OR SOMEPLACE WITH SOME"
|
||||
240 PRINT "REAL ACTION."
|
||||
250 PRINT
|
||||
255 PRINT "ANY MORE PROBLEMS YOU WANT SOLVED, ";N$;
|
||||
260 INPUT E$: PRINT
|
||||
270 IF E$="YES" THEN 280
|
||||
273 IF E$="NO" THEN 300
|
||||
275 PRINT "JUST A SIMPLE 'YES' OR 'NO' PLEASE, ";N$;"."
|
||||
277 GOTO 255
|
||||
280 PRINT "WHAT KIND (SEX, MONEY, HEALTH, JOB)";
|
||||
282 GOTO 125
|
||||
300 PRINT
|
||||
302 PRINT "THAT WILL BE $5.00 FOR THE ADVICE, ";N$;"."
|
||||
305 PRINT "PLEASE LEAVE THE MONEY ON THE TERMINAL."
|
||||
307 FOR I=1 TO 2000: NEXT I
|
||||
310 PRINT: PRINT: PRINT
|
||||
315 PRINT "DID YOU LEAVE THE MONEY";
|
||||
320 INPUT G$: PRINT
|
||||
325 IF G$="YES" THEN 350
|
||||
330 IF G$="NO" THEN 370
|
||||
335 PRINT "YOUR ANSWER OF '";G$;"' CONFUSES ME, ";N$;"."
|
||||
340 PRINT "PLEASE RESPOND WITH 'YES' OR 'NO'.": GOTO 315
|
||||
350 PRINT "HEY, ";N$;"??? YOU LEFT NO MONEY AT ALL!"
|
||||
355 PRINT "YOU ARE CHEATING ME OUT OF MY HARD-EARNED LIVING."
|
||||
360 PRINT:PRINT "WHAT A RIP OFF, ";N$;"!!!":PRINT
|
||||
365 GOTO 385
|
||||
370 PRINT "THAT'S HONEST, ";N$;", BUT HOW DO YOU EXPECT"
|
||||
375 PRINT "ME TO GO ON WITH MY PSYCHOLOGY STUDIES IF MY PATIENTS"
|
||||
380 PRINT "DON'T PAY THEIR BILLS?"
|
||||
385 PRINT:PRINT "TAKE A WALK, ";N$;".":PRINT:PRINT:GOTO 999
|
||||
390 PRINT "NICE MEETING YOU, ";N$;", HAVE A NICE DAY."
|
||||
400 REM
|
||||
999 END
|
||||
216
45_Hello/java/Hello.java
Normal file
216
45_Hello/java/Hello.java
Normal file
@@ -0,0 +1,216 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Game of Hello
|
||||
* <p>
|
||||
* Based on the BASIC game of Hello here
|
||||
* https://github.com/coding-horror/basic-computer-games/blob/main/45%20Hello/hello.bas
|
||||
* <p>
|
||||
* Note: The idea was to create a version of the 1970's BASIC game in Java, without introducing
|
||||
* new features - no additional text, error checking, etc has been added.
|
||||
*
|
||||
* Converted from BASIC to Java by Darren Cardenas.
|
||||
*/
|
||||
|
||||
public class Hello {
|
||||
|
||||
private static final int MONEY_WAIT_MS = 3000;
|
||||
|
||||
private final boolean goodEnding = false;
|
||||
|
||||
private final Scanner scan; // For user input
|
||||
|
||||
public Hello() {
|
||||
|
||||
scan = new Scanner(System.in);
|
||||
|
||||
} // End of constructor Hello
|
||||
|
||||
public void play() {
|
||||
|
||||
showIntro();
|
||||
startGame();
|
||||
|
||||
} // End of method play
|
||||
|
||||
private static void showIntro() {
|
||||
|
||||
System.out.println(" ".repeat(32) + "HELLO");
|
||||
System.out.println(" ".repeat(14) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
|
||||
System.out.println("\n\n");
|
||||
|
||||
} // End of method showIntro
|
||||
|
||||
private void startGame() {
|
||||
|
||||
boolean moreProblems = true;
|
||||
|
||||
String userCategory = "";
|
||||
String userName = "";
|
||||
String userResponse = "";
|
||||
|
||||
// Name question
|
||||
System.out.println("HELLO. MY NAME IS CREATIVE COMPUTER.\n\n");
|
||||
System.out.print("WHAT'S YOUR NAME? ");
|
||||
userName = scan.nextLine();
|
||||
System.out.println("");
|
||||
|
||||
// Enjoyment question
|
||||
System.out.print("HI THERE, " + userName + ", ARE YOU ENJOYING YOURSELF HERE? ");
|
||||
|
||||
while (true) {
|
||||
userResponse = scan.nextLine();
|
||||
System.out.println("");
|
||||
|
||||
if (userResponse.toUpperCase().equals("YES")) {
|
||||
System.out.println("I'M GLAD TO HEAR THAT, " + userName + ".\n");
|
||||
break;
|
||||
}
|
||||
else if (userResponse.toUpperCase().equals("NO")) {
|
||||
System.out.println("OH, I'M SORRY TO HEAR THAT, " + userName + ". MAYBE WE CAN");
|
||||
System.out.println("BRIGHTEN UP YOUR VISIT A BIT.");
|
||||
break;
|
||||
}
|
||||
else {
|
||||
System.out.println(userName + ", I DON'T UNDERSTAND YOUR ANSWER OF '" + userResponse + "'.");
|
||||
System.out.print("PLEASE ANSWER 'YES' OR 'NO'. DO YOU LIKE IT HERE? ");
|
||||
}
|
||||
}
|
||||
|
||||
// Category question
|
||||
System.out.println("");
|
||||
System.out.println("SAY, " + userName + ", I CAN SOLVE ALL KINDS OF PROBLEMS EXCEPT");
|
||||
System.out.println("THOSE DEALING WITH GREECE. WHAT KIND OF PROBLEMS DO");
|
||||
System.out.print("YOU HAVE (ANSWER SEX, HEALTH, MONEY, OR JOB)? ");
|
||||
|
||||
while (moreProblems) {
|
||||
userCategory = scan.nextLine();
|
||||
System.out.println("");
|
||||
|
||||
// Sex advice
|
||||
if (userCategory.toUpperCase().equals("SEX")) {
|
||||
System.out.print("IS YOUR PROBLEM TOO MUCH OR TOO LITTLE? ");
|
||||
userResponse = scan.nextLine();
|
||||
System.out.println("");
|
||||
|
||||
while (true) {
|
||||
if (userResponse.toUpperCase().equals("TOO MUCH")) {
|
||||
System.out.println("YOU CALL THAT A PROBLEM?!! I SHOULD HAVE SUCH PROBLEMS!");
|
||||
System.out.println("IF IT BOTHERS YOU, " + userName + ", TAKE A COLD SHOWER.");
|
||||
break;
|
||||
}
|
||||
else if (userResponse.toUpperCase().equals("TOO LITTLE")) {
|
||||
System.out.println("WHY ARE YOU HERE IN SUFFERN, " + userName + "? YOU SHOULD BE");
|
||||
System.out.println("IN TOKYO OR NEW YORK OR AMSTERDAM OR SOMEPLACE WITH SOME");
|
||||
System.out.println("REAL ACTION.");
|
||||
break;
|
||||
}
|
||||
else {
|
||||
System.out.println("DON'T GET ALL SHOOK, " + userName + ", JUST ANSWER THE QUESTION");
|
||||
System.out.print("WITH 'TOO MUCH' OR 'TOO LITTLE'. WHICH IS IT? ");
|
||||
userResponse = scan.nextLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Health advice
|
||||
else if (userCategory.toUpperCase().equals("HEALTH")) {
|
||||
System.out.println("MY ADVICE TO YOU " + userName + " IS:");
|
||||
System.out.println(" 1. TAKE TWO ASPRIN");
|
||||
System.out.println(" 2. DRINK PLENTY OF FLUIDS (ORANGE JUICE, NOT BEER!)");
|
||||
System.out.println(" 3. GO TO BED (ALONE)");
|
||||
}
|
||||
// Money advice
|
||||
else if (userCategory.toUpperCase().equals("MONEY")) {
|
||||
System.out.println("SORRY, " + userName + ", I'M BROKE TOO. WHY DON'T YOU SELL");
|
||||
System.out.println("ENCYCLOPEADIAS OR MARRY SOMEONE RICH OR STOP EATING");
|
||||
System.out.println("SO YOU WON'T NEED SO MUCH MONEY?");
|
||||
}
|
||||
// Job advice
|
||||
else if (userCategory.toUpperCase().equals("JOB")) {
|
||||
System.out.println("I CAN SYMPATHIZE WITH YOU " + userName + ". I HAVE TO WORK");
|
||||
System.out.println("VERY LONG HOURS FOR NO PAY -- AND SOME OF MY BOSSES");
|
||||
System.out.println("REALLY BEAT ON MY KEYBOARD. MY ADVICE TO YOU, " + userName + ",");
|
||||
System.out.println("IS TO OPEN A RETAIL COMPUTER STORE. IT'S GREAT FUN.");
|
||||
}
|
||||
else {
|
||||
System.out.println("OH, " + userName + ", YOUR ANSWER OF " + userCategory + " IS GREEK TO ME.");
|
||||
}
|
||||
|
||||
// More problems question
|
||||
while (true) {
|
||||
System.out.println("");
|
||||
System.out.print("ANY MORE PROBLEMS YOU WANT SOLVED, " + userName + "? ");
|
||||
userResponse = scan.nextLine();
|
||||
System.out.println("");
|
||||
|
||||
if (userResponse.toUpperCase().equals("YES")) {
|
||||
System.out.print("WHAT KIND (SEX, MONEY, HEALTH, JOB)? ");
|
||||
break;
|
||||
}
|
||||
else if (userResponse.toUpperCase().equals("NO")) {
|
||||
moreProblems = false;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
System.out.println("JUST A SIMPLE 'YES' OR 'NO' PLEASE, " + userName + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Payment question
|
||||
System.out.println("");
|
||||
System.out.println("THAT WILL BE $5.00 FOR THE ADVICE, " + userName + ".");
|
||||
System.out.println("PLEASE LEAVE THE MONEY ON THE TERMINAL.");
|
||||
|
||||
// Pause
|
||||
try {
|
||||
Thread.sleep(MONEY_WAIT_MS);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Caught Exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println("\n\n");
|
||||
|
||||
while (true) {
|
||||
System.out.print("DID YOU LEAVE THE MONEY? ");
|
||||
userResponse = scan.nextLine();
|
||||
System.out.println("");
|
||||
|
||||
if (userResponse.toUpperCase().equals("YES")) {
|
||||
System.out.println("HEY, " + userName + "??? YOU LEFT NO MONEY AT ALL!");
|
||||
System.out.println("YOU ARE CHEATING ME OUT OF MY HARD-EARNED LIVING.");
|
||||
System.out.println("");
|
||||
System.out.println("WHAT A RIP OFF, " + userName + "!!!\n");
|
||||
break;
|
||||
}
|
||||
else if (userResponse.toUpperCase().equals("NO")) {
|
||||
System.out.println("THAT'S HONEST, " + userName + ", BUT HOW DO YOU EXPECT");
|
||||
System.out.println("ME TO GO ON WITH MY PSYCHOLOGY STUDIES IF MY PATIENTS");
|
||||
System.out.println("DON'T PAY THEIR BILLS?");
|
||||
break;
|
||||
}
|
||||
else {
|
||||
System.out.println("YOUR ANSWER OF '" + userResponse + "' CONFUSES ME, " + userName + ".");
|
||||
System.out.println("PLEASE RESPOND WITH 'YES' OR 'NO'.");
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy included unreachable code
|
||||
if (goodEnding) {
|
||||
System.out.println("NICE MEETING YOU, " + userName + ", HAVE A NICE DAY.");
|
||||
}
|
||||
else {
|
||||
System.out.println("");
|
||||
System.out.println("TAKE A WALK, " + userName + ".\n");
|
||||
}
|
||||
|
||||
} // End of method startGame
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Hello hello = new Hello();
|
||||
hello.play();
|
||||
|
||||
} // End of method main
|
||||
|
||||
} // End of class Hello
|
||||
3
45_Hello/java/README.md
Normal file
3
45_Hello/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/)
|
||||
3
45_Hello/javascript/README.md
Normal file
3
45_Hello/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
45_Hello/javascript/hello.html
Normal file
9
45_Hello/javascript/hello.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>HELLO</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="hello.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
163
45_Hello/javascript/hello.js
Normal file
163
45_Hello/javascript/hello.js
Normal file
@@ -0,0 +1,163 @@
|
||||
// HELLO
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Main control section
|
||||
async function main()
|
||||
{
|
||||
print(tab(33) + "HELLO\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("HELLO. MY NAME IS CREATIVE COMPUTER.\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("WHAT'S YOUR NAME");
|
||||
ns = await input();
|
||||
print("\n");
|
||||
print("HI THERE, " + ns + ", ARE YOU ENJOYING YOURSELF HERE");
|
||||
while (1) {
|
||||
bs = await input();
|
||||
print("\n");
|
||||
if (bs == "YES") {
|
||||
print("I'M GLAD TO HEAR THAT, " + ns + ".\n");
|
||||
print("\n");
|
||||
break;
|
||||
} else if (bs == "NO") {
|
||||
print("OH, I'M SORRY TO HEAR THAT, " + ns + ". MAYBE WE CAN\n");
|
||||
print("BRIGHTEN UP YOUR VISIT A BIT.\n");
|
||||
break;
|
||||
} else {
|
||||
print("PLEASE ANSWER 'YES' OR 'NO'. DO YOU LIKE IT HERE");
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
print("SAY, " + ns + ", I CAN SOLVED ALL KINDS OF PROBLEMS EXCEPT\n");
|
||||
print("THOSE DEALING WITH GREECE. WHAT KIND OF PROBLEMS DO\n");
|
||||
print("YOU HAVE (ANSWER SEX, HEALTH, MONEY, OR JOB)");
|
||||
while (1) {
|
||||
cs = await input();
|
||||
print("\n");
|
||||
if (cs != "SEX" && cs != "HEALTH" && cs != "MONEY" && cs != "JOB") {
|
||||
print("OH, " + ns + ", YOUR ANSWER OF " + cs + " IS GREEK TO ME.\n");
|
||||
} else if (cs == "JOB") {
|
||||
print("I CAN SYMPATHIZE WITH YOU " + ns + ". I HAVE TO WORK\n");
|
||||
print("VERY LONG HOURS FOR NO PAY -- AND SOME OF MY BOSSES\n");
|
||||
print("REALLY BEAT ON MY KEYBOARD. MY ADVICE TO YOU, " + ns + ",\n");
|
||||
print("IS TO OPEN A RETAIL COMPUTER STORE. IT'S GREAT FUN.\n");
|
||||
} else if (cs == "MONEY") {
|
||||
print("SORRY, " + ns + ", I'M BROKE TOO. WHY DON'T YOU SELL\n");
|
||||
print("ENCYCLOPEADIAS OR MARRY SOMEONE RICH OR STOP EATING\n");
|
||||
print("SO YOU WON'T NEED SO MUCH MONEY?\n");
|
||||
} else if (cs == "HEALTH") {
|
||||
print("MY ADVICE TO YOU " + ns + " IS:\n");
|
||||
print(" 1. TAKE TWO ASPRIN\n");
|
||||
print(" 2. DRINK PLENTY OF FLUIDS (ORANGE JUICE, NOT BEER!)\n");
|
||||
print(" 3. GO TO BED (ALONE)\n");
|
||||
} else {
|
||||
print("IS YOUR PROBLEM TOO MUCH OR TOO LITTLE");
|
||||
while (1) {
|
||||
ds = await input();
|
||||
print("\n");
|
||||
if (ds == "TOO MUCH") {
|
||||
print("YOU CALL THAT A PROBLEM?!! I SHOULD HAVE SUCH PROBLEMS!\n");
|
||||
print("IF IT BOTHERS YOU, " + ns + ", TAKE A COLD SHOWER.\n");
|
||||
break;
|
||||
} else if (ds == "TOO LITTLE") {
|
||||
print("WHY ARE YOU HERE IN SUFFERN, " + ns + "? YOU SHOULD BE\n");
|
||||
print("IN TOKYO OR NEW YORK OR AMSTERDAM OR SOMEPLACE WITH SOME\n");
|
||||
print("REAL ACTION.\n");
|
||||
break;
|
||||
} else {
|
||||
print("DON'T GET ALL SHOOK, " + ns + ", JUST ANSWER THE QUESTION\n");
|
||||
print("WITH 'TOO MUCH' OR 'TOO LITTLE'. WHICH IS IT");
|
||||
}
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
print("ANY MORE PROBLEMS YOU WANT SOLVED, " + ns);
|
||||
es = await input();
|
||||
print("\n");
|
||||
if (es == "YES") {
|
||||
print("WHAT KIND (SEX, MONEY, HEALTH, JOB)");
|
||||
} else if (es == "NO") {
|
||||
print("THAT WILL BE $5.00 FOR THE ADVICE, " + ns + ".\n");
|
||||
print("PLEASE LEAVE THE MONEY ON THE TERMINAL.\n");
|
||||
print("\n");
|
||||
// d = new Date().valueOf();
|
||||
// while (new Date().valueOf() - d < 2000) ;
|
||||
print("\n");
|
||||
print("\n");
|
||||
while (1) {
|
||||
print("DID YOU LEAVE THE MONEY");
|
||||
gs = await input();
|
||||
print("\n");
|
||||
if (gs == "YES") {
|
||||
print("HEY, " + ns + "??? YOU LEFT NO MONEY AT ALL!\n");
|
||||
print("YOU ARE CHEATING ME OUT OF MY HARD-EARNED LIVING.\n");
|
||||
print("\n");
|
||||
print("WHAT A RIP OFF, " + ns + "!!!\n");
|
||||
print("\n");
|
||||
break;
|
||||
} else if (gs == "NO") {
|
||||
print("THAT'S HONEST, " + ns + ", BUT HOW DO YOU EXPECT\n");
|
||||
print("ME TO GO ON WITH MY PSYCHOLOGY STUDIES IF MY PATIENT\n");
|
||||
print("DON'T PAY THEIR BILLS?\n");
|
||||
break;
|
||||
} else {
|
||||
print("YOUR ANSWER OF '" + gs + "' CONFUSES ME, " + ns + ".\n");
|
||||
print("PLEASE RESPOND WITH 'YES' OR 'NO'.\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
print("TAKE A WALK, " + ns + ".\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
// Line 390 not used in original
|
||||
}
|
||||
|
||||
main();
|
||||
3
45_Hello/pascal/README.md
Normal file
3
45_Hello/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
45_Hello/perl/README.md
Normal file
3
45_Hello/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/)
|
||||
3
45_Hello/python/README.md
Normal file
3
45_Hello/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/)
|
||||
207
45_Hello/python/hello.py
Normal file
207
45_Hello/python/hello.py
Normal file
@@ -0,0 +1,207 @@
|
||||
"""
|
||||
HELLO
|
||||
|
||||
A very simple "chat" bot.
|
||||
|
||||
Warning, the advice given here is bad.
|
||||
|
||||
Ported by Dave LeCompte
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
|
||||
def print_with_tab(space_count, msg):
|
||||
if space_count > 0:
|
||||
spaces = " " * space_count
|
||||
else:
|
||||
spaces = ""
|
||||
print(spaces + msg)
|
||||
|
||||
|
||||
def get_yes_or_no():
|
||||
msg = input()
|
||||
if msg.upper() == "YES":
|
||||
return True, True, msg
|
||||
elif msg.upper() == "NO":
|
||||
return True, False, msg
|
||||
else:
|
||||
return False, None, msg
|
||||
|
||||
|
||||
def ask_enjoy_question(user_name):
|
||||
print(f"HI THERE, {user_name}, ARE YOU ENJOYING YOURSELF HERE?")
|
||||
|
||||
has_answer = False
|
||||
while True:
|
||||
valid, value, msg = get_yes_or_no()
|
||||
|
||||
if valid:
|
||||
if value:
|
||||
print(f"I'M GLAD TO HEAR THAT, {user_name}.")
|
||||
print()
|
||||
else:
|
||||
print(f"OH, I'M SORRY TO HEAR THAT, {user_name}. MAYBE WE CAN")
|
||||
print("BRIGHTEN UP YOUR VISIT A BIT.")
|
||||
break
|
||||
else:
|
||||
print(f"{user_name}, I DON'T UNDERSTAND YOUR ANSWER OF '{msg}'.")
|
||||
print("PLEASE ANSWER 'YES' OR 'NO'. DO YOU LIKE IT HERE?")
|
||||
|
||||
|
||||
def prompt_for_problems(user_name):
|
||||
print()
|
||||
print(f"SAY, {user_name}, I CAN SOLVE ALL KINDS OF PROBLEMS EXCEPT")
|
||||
print("THOSE DEALING WITH GREECE. WHAT KIND OF PROBLEMS DO")
|
||||
print("YOU HAVE? (ANSWER SEX, HEALTH, MONEY, OR JOB)")
|
||||
|
||||
problem_type = input().upper()
|
||||
return problem_type
|
||||
|
||||
|
||||
def prompt_too_much_or_too_little():
|
||||
answer = input().upper()
|
||||
if answer == "TOO MUCH":
|
||||
return True, True
|
||||
elif answer == "TOO LITTLE":
|
||||
return True, False
|
||||
return False, None
|
||||
|
||||
|
||||
def solve_sex_problem(user_name):
|
||||
print("IS YOUR PROBLEM TOO MUCH OR TOO LITTLE?")
|
||||
while True:
|
||||
valid, too_much = prompt_too_much_or_too_little()
|
||||
if valid:
|
||||
if too_much:
|
||||
print(f"YOU CALL THAT A PROBLEM?!! I SHOULD HAVE SUCH PROBLEMS!")
|
||||
print(f"IF IT BOTHERS YOU, {user_name}, TAKE A COLD SHOWER.")
|
||||
else:
|
||||
print(f"WHY ARE YOU HERE IN SUFFERN, {user_name}? YOU SHOULD BE")
|
||||
print(f"IN TOKYO OR NEW YORK OR AMSTERDAM OR SOMEPLACE WITH SOME")
|
||||
print(f"REAL ACTION.")
|
||||
return
|
||||
else:
|
||||
print(f"DON'T GET ALL SHOOK, {user_name}, JUST ANSWER THE QUESTION")
|
||||
print(f"WITH 'TOO MUCH' OR 'TOO LITTLE'. WHICH IS IT?")
|
||||
|
||||
|
||||
def solve_money_problem(user_name):
|
||||
print(f"SORRY, {user_name}, I'M BROKE TOO. WHY DON'T YOU SELL")
|
||||
print("ENCYCLOPEADIAS OR MARRY SOMEONE RICH OR STOP EATING")
|
||||
print("SO YOU WON'T NEED SO MUCH MONEY?")
|
||||
|
||||
|
||||
def solve_health_problem(user_name):
|
||||
print(f"MY ADVICE TO YOU {user_name} IS:")
|
||||
print(" 1. TAKE TWO ASPRIN")
|
||||
print(" 2. DRINK PLENTY OF FLUIDS (ORANGE JUICE, NOT BEER!)")
|
||||
print(" 3. GO TO BED (ALONE)")
|
||||
|
||||
|
||||
def solve_job_problem(user_name):
|
||||
print(f"I CAN SYMPATHIZE WITH YOU {user_name}. I HAVE TO WORK")
|
||||
print("VERY LONG HOURS FOR NO PAY -- AND SOME OF MY BOSSES")
|
||||
print(f"REALLY BEAT ON MY KEYBOARD. MY ADVICE TO YOU, {user_name},")
|
||||
print("IS TO OPEN A RETAIL COMPUTER STORE. IT'S GREAT FUN.")
|
||||
|
||||
|
||||
def alert_unknown_problem_type(user_name, problem_type):
|
||||
print(f"OH, {user_name}, YOUR ANSWER OF {problem_type} IS GREEK TO ME.")
|
||||
|
||||
|
||||
def ask_question_loop(user_name):
|
||||
while True:
|
||||
problem_type = prompt_for_problems(user_name)
|
||||
if problem_type == "SEX":
|
||||
solve_sex_problem(user_name)
|
||||
elif problem_type == "HEALTH":
|
||||
solve_health_problem(user_name)
|
||||
elif problem_type == "MONEY":
|
||||
solve_money_problem(user_name)
|
||||
elif problem_type == "JOB":
|
||||
solve_job_problem(user_name)
|
||||
else:
|
||||
alert_unknown_problem_type(user_name, problem_type)
|
||||
|
||||
while True:
|
||||
print()
|
||||
print(f"ANY MORE PROBLEMS YOU WANT SOLVED, {user_name}?")
|
||||
|
||||
valid, value, msg = get_yes_or_no()
|
||||
if valid:
|
||||
if value:
|
||||
print("WHAT KIND (SEX, MONEY, HEALTH, JOB)")
|
||||
break
|
||||
else:
|
||||
return
|
||||
print(f"JUST A SIMPLE 'YES' OR 'NO' PLEASE, {user_name}.")
|
||||
|
||||
|
||||
def ask_for_fee(user_name):
|
||||
print()
|
||||
print(f"THAT WILL BE $5.00 FOR THE ADVICE, {user_name}.")
|
||||
print(f"PLEASE LEAVE THE MONEY ON THE TERMINAL.")
|
||||
time.sleep(4)
|
||||
print()
|
||||
print()
|
||||
print()
|
||||
print("DID YOU LEAVE THE MONEY?")
|
||||
|
||||
while True:
|
||||
valid, value, msg = get_yes_or_no()
|
||||
if valid:
|
||||
if value:
|
||||
print(f"HEY, {user_name}, YOU LEFT NO MONEY AT ALL!")
|
||||
print("YOU ARE CHEATING ME OUT OF MY HARD-EARNED LIVING.")
|
||||
print()
|
||||
print(f"WHAT A RIP OFF, {user_name}!!!")
|
||||
print()
|
||||
else:
|
||||
print(f"THAT'S HONEST, {user_name}, BUT HOW DO YOU EXPECT")
|
||||
print("ME TO GO ON WITH MY PSYCHOLOGY STUDIES IF MY PATIENTS")
|
||||
print("DON'T PAY THEIR BILLS?")
|
||||
return
|
||||
else:
|
||||
print(f"YOUR ANSWER OF '{msg}' CONFUSES ME, {user_name}.")
|
||||
print("PLEASE RESPOND WITH 'YES' or 'NO'.")
|
||||
|
||||
|
||||
def unhappy_goodbye(user_name):
|
||||
print()
|
||||
print(f"TAKE A WALK, {user_name}.")
|
||||
print()
|
||||
print()
|
||||
|
||||
|
||||
def happy_goodbye(user_name):
|
||||
print(f"NICE MEETING YOU, {user_name}, HAVE A NICE DAY.")
|
||||
|
||||
|
||||
def main():
|
||||
print_with_tab(33, "HELLO")
|
||||
print_with_tab(15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
print()
|
||||
print()
|
||||
print()
|
||||
print("HELLO. MY NAME IS CREATIVE COMPUTER.")
|
||||
print()
|
||||
print()
|
||||
print("WHAT'S YOUR NAME?")
|
||||
user_name = input()
|
||||
print()
|
||||
|
||||
ask_enjoy_question(user_name)
|
||||
|
||||
ask_question_loop(user_name)
|
||||
|
||||
ask_for_fee(user_name)
|
||||
|
||||
if False:
|
||||
happy_goodbye(user_name)
|
||||
else:
|
||||
unhappy_goodbye(user_name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
3
45_Hello/ruby/README.md
Normal file
3
45_Hello/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
45_Hello/vbnet/README.md
Normal file
3
45_Hello/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