Add early projects markdown file.

This commit is contained in:
Danila Fedorin 2020-08-12 14:48:56 -07:00
commit 77074f02e6

123
README.md Normal file
View File

@ -0,0 +1,123 @@
# Early CS 162 Projects
My archives appear rather incomplete; I'm missing the source
code for the small, introductory projects at the beginning
of the class. For posterity, I will document them here.
## Guessing Game
The guessing game program must generate a random number
between 1 and 100. It must then prompt the user to guess
the number. If the guess is exactly right, the game
ends. Otherwise, if the number is too low or too
high, the game must tell the user so, and prompt
them for another guess. The player keeps guessing
until they get the right answer.
Here's an example:
```
I'm thinking of a number between 1 and 100. What is it?
> 50
That's too low! Guess again.
> 75
That's too low! Guess again.
> 87
That's too low! Guess again.
> 93
That's too high! Guess again.
> 92
Correct!
```
## Palindrome
The palindrome program must ask the user to enter
a string of text. Any string of text should be supported,
like `"hello"` `"my name is daniel"`, `"one, two, three!"`.
Then, the program must print to the console whether
or not the input string is a palindrome. A palindrome
is a word or sentence that, when read backwards, is
exactly the same thing. Here are some examples:
```
> hello
This string is not a palindrome!
> lol
This string is a palindrome!
> a man, a plan, a canal: panama!
This string is a palindrome!
```
## Tic Tac Toe
This is a simple game of Tic-Tac-Toe. We start with
an empty 3x3 board, and two players can take turns placing
their symbol (`X` or `O`) on the board. The game ends when
a player makes a line out of their symbol (3 horizontal, 3 vertical,
or 3 diagonal). The game also ends when there are no possible
moves. Here's an example:
```
A B C
.---.---.---.
1 | | | |
.---.---.---.
2 | | | |
.---.---.---.
3 | | | |
.---.---.---|
Player 1> A1
A B C
.---.---.---.
1 | X | | |
.---.---.---.
2 | | | |
.---.---.---.
3 | | | |
.---.---.---|
Player 2> A3
A B C
.---.---.---.
1 | X | | |
.---.---.---.
2 | | | |
.---.---.---.
3 | O | | |
.---.---.---|
Player 1> B2
A B C
.---.---.---.
1 | X | | |
.---.---.---.
2 | | X | |
.---.---.---.
3 | O | | |
.---.---.---|
Player 2> B3
A B C
.---.---.---.
1 | X | | |
.---.---.---.
2 | | X | |
.---.---.---.
3 | O | O | |
.---.---.---|
Player 1> C3
A B C
.---.---.---.
1 | X | | |
.---.---.---.
2 | | X | |
.---.---.---.
3 | O | O | X |
.---.---.---|
Player 1 wins!
```