1. Setup

1.1. DrRacket

  1. Download and install the DrRacket Version 6.10. 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 and select `

    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

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.

    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.

    1. Download and install the GitHub application for OS X

    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.

1.2.1. Test your git setup

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

  1. lab1-<login>

  2. assignment1-<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 lab1-<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 right 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.2.2. Adding a file to your git repository

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

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

  2. No go back to your git application and from the left panel select your lab1-<login> repo.

  3. 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.

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

  5. 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

  6. 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

  7. Click on Commit to master.

  8. Select the repository lab1-<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.

  9. 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.

  10. 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 to commit and push your new changes to the CCIS GitHub 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
  • 2) Paste this code in your definitions window and click Run.

  • 3) Use the interactions window to calculate the tip for a bill amount of $35.

  • 4) Use check-expect to write tests for the function tip.

  • 5) 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
  • 6) Create a new function called tip-percentage that will take as input the bill amount and the percentage to be used for the tip.

  • 7) Use check-expect to write tests for the function tip-percentage.

  • 8) 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
  • 9) 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

  • 10) 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
  • 11) 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.

  • 12) 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
  • 13) 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=?

  • 14) Use check-expect to write tests for your new function.