# Session 2 Practice Tasks The assignments listed here should take you approximately 55 total minutes. **CAREFULLY READ ALL THE INSTRUCTIONS BEFORE STARTING THESE EXERCISES!** To start this assignment: 1. Click the button in the upper right-hand corner that says **Fork**. This is now your copy of the document. 1. Click the **Edit** button when you're ready to start adding your answers. 1. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist. ### 1. Creating Files and Directories (10 min) _Need help? You can go back to the files/directories portion of the lesson [here](http://mod0.turing.io/session2/#filesdirectories)._ Use commands in your terminal to create the directories and files structured exactly how they appear in the image below. ![image](https://user-images.githubusercontent.com/20710327/104334480-a8076900-54af-11eb-9a05-e4c49c95094c.png) When you're done, type `history` to see your commands. Copy and paste the commands that were used to create the directory and files: ``` paste your commands here ``` Since this is just a practice directory, feel free to remove the parent directory `session_3_practice` when you're done with this exercise. ### 2. Git Practice (15 min) Follow the steps below to practice the git workflow. Be ready to copy-paste your terminal output as confirmation of your practice. 1. Create a directory called `git_homework`. Inside of there, create a file called `variablePractice.js` (FE) or `variable_practice.rb` (BE). 1. Initialize the directory 1. Use `git status` to ensure you are set up for tracking using Git 1. Add your `variablePractice.js` OR `variable_practice.rb` file to the staging area 1. Check the `git status` 1. Create an initial commit (Note: Be sure to follow the correct message format for your first commit!) 1. Check the `git status` 1. Declare 6 variables in your`variablePractice.js` OR `variable_practice.rb` file. Be sure to include at least one example that uses strings, integers/numbers, arrays, and booleans! 1. Check the `git status` 1. Check the changes you've made using `git diff` 1. Add the changes to the staging area 1. Commit the new changes (Note: Be sure to follow convention for commit messages!) 1. Check the status 1. Using re-assignment syntax, re-assign 3 of your variables in your `variablePractice.js` OR `variable_practice.rb` file 1. Add the changes to the staging area 1. Commit the new changes (Note: Be sure to follow convention for commit messages!) 1. Show the log of your work in `oneline` format using `git log` (This will likely require some Googling) Copy and paste **all** of the terminal text from this process below (not just the history): ``` paste all of your terminal text here ``` **IMPORTANT**: Do **NOT** remove this `git_homework` directory. You will be using this directory during the next session. ### 3. Classes, Attributes, and Methods (15 min) Look at the template below for a `ConvenienceStore` class. Fill in missing blanks with additional attributes and methods. ``` Class: ConvenienceStore Attributes: - totalSales (integer) - _____ (integer) - address (string) - _____ (string) - isOpen (boolean) - ____ (boolean) - candyInventory (array) - _____ (array) **EXTENSION** Methods: - closeStore (updates the isOpen attribute to false) - updateTotalSales (updates the totalSales attribute with new sales data) - ______ (add what attribute the method updates here) - ______ (add what attribute the method updates here) - ______ (add what attribute the method updates here) ``` ### 4. Modify your Zsh Prompt (10 min) - Make sure that your shell is set to zsh by running the following command: `$ chsh -s /bin/zsh`. Remember to omit the `$`! Note that macOS Catalina and later operating systems already use zsh as the default shell. - [ ] Watch [this video](https://drive.google.com/file/d/1a4YAPJcrtecUQWxwGM5uRfn3Ue6-kHAW/view?usp=sharing) and follow each step to modify your own ```zshrc``` configuration file. As mentioned in the video, you will need this snippet below: ``` # Load version control information autoload -Uz vcs_info precmd() { vcs_info } # Format the vcs_info_msg_0_ variable zstyle ':vcs_info:git:*' formats '%b' # Determine if current working directory is a git repository git_branch_color() { if current_git_status=$(git status 2> /dev/null); then parse_git_dirty else echo "" fi } # Change branch color if working tree is clean parse_git_dirty() { if current_git_status=$(git status | grep 'Changes to be committed:\|Untracked files:\|modified:|deleted:' 2> /dev/null); then echo "%F{red}" else echo "%F{green}" fi } # Set up the prompt (with git branch name) setopt PROMPT_SUBST PROMPT='%F{white}%d $(git_branch_color)${vcs_info_msg_0_} %f$' ``` ### 5. Self Assess Using the rubric below, assess how you did with these exercises. These are the same metrics your instructors will use to determine if you are prepared for Mod 1! - [ ] I read carefully read ALL directions - [ ] I completed all parts of the exercises (not including Extensions) to the best of my ability - [ ] I used correct syntax, spacing and naming conventions - [ ] I followed ALL formatting instructions - [ ] I pushed myself out of my comfort zone and experimented/broke things to try to learn - [ ] I spent no longer than 20-30 mins Googling a specific problem before asking for help - [ ] I went back to the lesson to search for clarification before asking for help ### Stuck? Having Issues? Are you stuck on something? Here is the **BEST** way to ask for help: - Find the `Session 2 HW Thread` in your Mod 0 Slack channel - Start or reply in the thread with the problem you are facing. Be sure to follow the guidelines for asking questions below: - [ ] I can explain what I am trying to do or accomplish - [ ] I can what I have tried so far and/or what resources I've tried online - [ ] I can describe specifically what I am stuck on - [ ] I provided screenshots and/or code examples to give context - [ ] If I provided short code examples, I used `inline code formatting` for single lines of code/error messages - [ ] If I provided larger blocks of code, I used a [code snippet](https://slack.com/help/articles/204145658-Create-a-snippet) in the correct format (such as `.js` or `.rb`) - Usually, your classmates will be able to answer your question or point you in the right direction very quickly! If not, an instructor will reply within 24-48 hours ### Extensions 1. [This course](https://learnpythonthehardway.org/book/appendixa.html) is how I personally learned command line. If time permits, I highly recommend reading and practicing. 1. Also recommended by Jeff Casimir: [Michael Hartl's Learn Enough Command Line](https://www.learnenough.com/command-line-tutorial/basics).