1. Setup

1.1. DrRacket

  1. Download and install the DrRacket Version 6.6. Make sure that you select the appropriate link for your Operating System (Windows, OSX, Linux) and its version.

  2. Install DrRacket on your computer.

  3. Start DrRacket and select a language by

    1. clicking on the Language menu item

    2. select Choose Language

    3. Under the group titled Teaching Languages, select Beginning Student.

    4. Click on Run button on the top right corner of DrRacket’s window.

1.2. Git

1.2.1. Accept your CCIS GitHub Invitation

If you have not accepted our invitation to join the class' organization on GitHub, click here the incitation should appear in the top center of your browser. Click to accept it.

1.3. Installing and configuring Git

We are going to use Git and the CCIS GitHub server in Boston.

  • The Git command line tools. These do not come with a graphical application, but most documentation that you find online is based on the command line tools.

  • GitHub provides a graphical program for Windows. You will have to configure GitHub for Windows to communicate with the CCIS GitHub server.

    You can use the application’s instructions on how to connect to the Enterprise Github Server.

    1. Download and install the GitHub application for Windows

    2. Start the application

    3. From the main application menu, find Preferences and select it. A new window should appear

    4. In the new windoe find the section titled GitHub Enterprise

      1. For the field URL add https://github.ccs.neu.edu

      2. For the field Login add your CCIS GitHub login name; the same name you email the course staff on Piazza

      3. For the field Password add your CCIS password.

  • GitHub provides a graphical program for Macs. You will have to configure GitHub for Mac to communicate with the CCIS GitHub server.

    You can use the application’s instructions on how to connect to the Enterprise GitHub server.

1.3.1. Clone your repository

This step will download the folder from the server to your computer.

The class has an organization on the CCIS GitHub server called 2016FACS5001SEA. Each of you should have two repositories created.

  • lab-1-<login>

  • assignment-1-<login>

where <login> is your login name. These should appear on the right section of the web page when you navigate to the organization’s dashboard.

  1. Click on the lab-1-<login> repository.

  2. Your browser will show you the contents of the repository in a similar fashion to what your file explorer does on your computer. This is what the server has stored in its memory.

  3. Open your git application.

  4. Use the + button in the top left to clone a repository

    • for now you can think of clone as an equivalent to download for the first time.

  5. The Git application will ask you where to download the repository on your local machine. Select a folder of your choice.

  6. Use your file explorer to go to the folder that you just downloaded the repository

Git as a program keeps track of the files that you place in this repository. Git will also allow you to push (think of a push similar to upload files to the server) your new files, additions to existing files to the server. So lets do that.

1.3.2. Adding a file and pushing the file to the server

This step creates a file, adds it to your gihub repository and then pushed (or uploads) the file to the server.

  1. Open DrRacket and in the definitions window add the following text

    ; This is my first DrRacket comment
  2. Save this file inside the same folder as the one we download from the CCIS GitHub server with the name lab1-git-test.

  3. No go back to your git application and from the left panel select your lab-1-<login> repo.

  4. The git application will have the new file selected and the text inside the file in a green background. Git identified that we have added a new file on your computer that is not on the server.

  5. At the bottom of the git application’s window there are 2 text boxes and a button with the text Commit to master.

  6. The first text box reads Summary. Click inside the box and add a small comment that descibes the changes that we made, e.g., first comment

  7. The second text box reads Description. Click inside the box and add a small description of the changes we made, e.g., first comment to be committed to github

  8. Click on Commit to master.

  9. Select the repository lab-1-<login> from the left panel. Right click on it and select View in Github from the pop-up menu. A new browser window will open and take you to the CCIS GitHub server to show you the same repository on the server. Notice that our new file is not present on the server.

  10. Go back to your git application and in the top right corner of the window there is a button with the text Sync. Click it.

  11. Go back to your browser window that we just opened. Hit the refresh button on your browser’s window. The file should now appear on the server as well.

Practise Exercises
  1. Go back to your DrRacket window and add more comments and some code to the file. Follow the same process starting at step 3 to commit and push your new changes to the CCIS GitHub server.

1.3.3. Workflow for your assignments and labs

For the rest of the semester, we will be creating a new empty repository for each lab and assignment. Your steps for each new lab or assignment should be as follows

  1. Clone your empty repo first, see steps in Clone your repository. You only have to perform this step once.

  2. Create a new file that will store all of your code, see steps in Adding a file and pushing the file to the server.

  3. Add your work to this file. Keep uploading your code (clicking Sync) so that your code is also stored on the server.

2. DrRacket Functions

A classmate came up with a function to calculate a 20% tip for his restaurant bill. Here is his code

tip
(define (tip amount)
  (* amount 0.20))
Practise Exercises
  1. Paste this code in your definitions window and click Run.

  2. Use the interactions window to calculate the tip for a bill amount of $35.

  3. Use check-expect to write tests for the function tip.

  4. Use the Stepper to step through the evaluation of your tests.

Another classmate wants to use this function as well but they would like to choose the percentage to use for a tip every time.

Practise Exercises
  1. Create a new function called tip-percentage that will take as input the bill amount and the percentage to be used for the tip.

  2. Use check-expect to write tests for the function tip-percentage.

  3. Use the Stepper to step through the evaluation of your tests.

Another classmate heard about your function and wants to use it as well. They however would like to make a small addition. When the tip amount is not a whole number, i.e., 3.1, they would like to round the value to the nearest whole integer.

Practise Exercises
  1. Create a new function called tip-percentage-round that will round the tip amount to the nearest whole number. You might want to look up the documentation on round

  2. Use check-expect to write tests for the function tip-percentage-round.

3. Making decisions

Your tip program is getting very popular. People are asking for extensions to the program. One popular extension is the following.

  1. When the bill amount is less than or equal to $100 then the tip percentage is 15%

  2. When the bill amount is greater than 100 but less than 400 the tip percentage is 20%

  3. When the bill amount is greater or equal to 400 the tip percentage is 22%

Practise Exercises
  1. Create a new function that will implement the above logic. You can name the function as you wish. Make sure you provide a name that is descriptive.

  2. Use check-expect to write tests for your new function.

4. Creating Images

In order to create and manipulate images in DrRacket we need to make the image library available to our code. Add the following line to your definitions window

(require 2htdp/image)

The image library allows us to create all sorts of shapes. Have a look at the library’s documentation for more details.

Practise Exercises
  1. A friend is prototyping a small game. He asking you for help with the image generation. They would like you to develop a function that given one of three symbols draws the corresponding image, for example,

    1. Given 'circle it will generate a red circle with radius 100.

    2. Given 'square it will generate a blue square with side 50.

    3. Given 'star it will generate a green star with side 50. You should read the documentation on the function symbol=?

  2. Use check-expect to write tests for your new function.