master
Matt Huntington 7 years ago
parent be036c6f88
commit 2d6b67eaae

@ -5,9 +5,9 @@
### Day 1 ### Day 1
1. Morning Lecture: [Intro to PHP](day1/instructor_notes/PHP.md) 1. Morning Lecture: [Intro to PHP](day1/instructor_notes/PHP.md)
1. Morning Lab: Recreate Landscaper 1. Morning Lab: [Recreate Landscaper](day1/student_labs/morning.md)
1. Afternoon Lecture: [Intro to PHP 2](day1/instructor_notes/PHP2.md) 1. Afternoon Lecture: [Intro to PHP 2](day1/instructor_notes/PHP2.md)
1. Afternoon Lab: Continue with Recreate Landscaper 1. Afternoon Lab: [Continue with Recreate Landscaper](day1/student_labs/afternoon.md)
1. Homework: Mimic Find/All with 2D Arrays and Nested Objects 1. Homework: Mimic Find/All with 2D Arrays and Nested Objects
### Day 2 ### Day 2

@ -0,0 +1,3 @@
# Lab
Continue with [the morning lab](morning.md)

@ -0,0 +1,126 @@
# Landscaper
![studio ghibli landscape](https://peakmemory.files.wordpress.com/2014/06/cliufqx.jpg)
You'll be creating a simple, terminal-based PHP game.
#### Learning Objectives
- Putting everything you've learned so far together (arrays, loops, conditionals, functions)
#### Prerequisites
- PHP (arrays, loops, conditionals, functions)
---
## Getting Started
1. Create a `landscaper.php` inside this folder.
## Landscaper
1. You are starting a landscaping business, but all you have are your teeth.
1. Using just your teeth, you can spend the day cutting lawns and make $1. You can do this as much as you want.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can use teeth to cut grass"
<hr>
1. At any point, if you are currently using your teeth, you can buy a pair of rusty scissors for $5. You can do this once, assuming you have enough money.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can buy scissors"
<hr>
1. Using the rusty scissors, you can spend the day cutting lawns and make $5. You can do this as much as you want.
<hr>
&#x1F534; Commit: <br>
"Landscaper App: user can use scissors to cut grass"
<hr>
1. At any point, if you are currently using rusty scissors, you can buy an old-timey push lawnmower for $25. You can do this once, assuming you have enough money.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can buy push lawnmower"
<hr>
1. Using the old-timey push lawnmower, you can spend the day cutting lawns and make $50. You can do this as much as you want.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can use push lawnmower to cut grass"
<hr>
1. At any point, if you are currently using the old-timey push lawnmower, you can buy a fancy battery-powered lawnmower for $250. You can do this once, assuming you have enough money.
<hr>
&#x1F534; <b>Commit your work!</b><br>
Your commit message should read something like: <br>
"landscaper: user can buy battery-powered lawnmower"
<hr>
1. Using the the fancy battery-powered lawnmower, you can spend the day cutting lawns and make $100. You can do this as much as you want.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can use battery-powered lawnmower to cut grass"
<hr>
1. At any point, if you are currently using the fancy battery-powered lawnmower, you can hire a team of starving students for $500. You can do this once, assuming you have enough money.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can hire a team"
<hr>
1. Using the the team of starving students, you can spend the day cutting lawns and make $250. You can do this as much as you want.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: user can use a team to cut grass"
<hr>
1. You win the game when you have a team of starving students and $1000. In this situation, send a message to the user telling them, they've won.
<hr>
&#x1F534; <b>Commit your work!</b> <br>
Your commit message should read something like: <br>
"landscaper: win scenario"
<hr>
## Deliverables
For this section of the homework, inside the `landscaper` folder you should have an and `app.php` that simulates the landscaper game outlined above. Your app must have:
- The ability to take user input
- The ability for the user to earn money
- The ability to buy tools and use the new tool
- The ability to win the game and end it
- _Hint:_ Try setting the win amount to $10 frst, then $50, and etc. until you get to the end to allow for easier testing!
## Technical Requirements
1. Your landscaper game *must* run on first load with no syntax errors
1. If there are errors you can't solve, comment them out and leave a comment above it explaining what is wrong
## Submission Guidelines
- Submit your homework via github issues and please don't forget to fill out the form!
## Hungry for More?
1. Add the ability to reset the game at any point so that you can play again
1. Make it so that a user can have multiple tools, and money earned each day is increased appropriately (e.g. 2 scissors, and an old-timey push lawnmower means you earn $60/day )
1. Once you've implemented multiple tools, make it so you can sell tools for half price

@ -0,0 +1,43 @@
# Lab - Landscaper
## Description
Remember the landscaper app you built in unit 1? Well, now recreate it using PHP. You'll do it in the terminal though, because it's actually really easy to run php in the terminal. First off, the command to run a php file in the terminal is just:
```
php yourfile.php
```
Keep in mind you'll have to change `yourfile.php` to the name of the file you write your code in.
Next, the following code is all you need in order to get input from the user in the terminal:
```php
$response = trim(fgets( STDIN ));
```
Now `$response` will hold whatever the user types into the terminal (they'll have to hit enter when they're done typing). If you want, research what each function does, but don't worry if you just want to copy paste.
Here's the beginnings of an app that starts the user off with an initial amount of apples/money and then asks them what they want to do. It only runs once though. If you feel like it, as a starting point, try to make it work so that this sample app will continue until the user runs out of money.
```php
<?php
$apples = 0;
$money = 20;
echo "What would you like to do? Eat an apple or buy an apple?\n";
echo "eat/buy\n";
$response = trim(fgets( STDIN ));
if($response === "eat"){
$apples--;
echo "you have " . $apples . " apples and $" . $money ."\n";
} else {
$apples++;
$money--;
echo "you have " . $apples . " apples and $" . $money ."\n";
}
?>
```
Note the `\n` that's used to add a new line in the terminal
## In case you forgot how the landscaper should run:
Loading…
Cancel
Save