1. Setup
1.1. DrRacket
-
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.
-
Install DrRacket on your computer.
-
Start DrRacket and select a language by
-
clicking on the
Language
menu item and select ` -
select
Choose Language
-
Under the group titled
Teaching Languages
, selectBeginning Student
. -
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.
-
Download and install the GitHub application for Windows
-
Start the application
-
From the main application menu, find Preferences and select it. A new window should appear
-
In the new windoe find the section titled
GitHub Enterprise
-
For the field
URL
add https://github.ccs.neu.edu -
For the field
Login
add your CCIS GitHub login name; the same name you email the course staff on Piazza -
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.
-
Download and install the GitHub application for OS X
-
Start the application
-
From the main application menu, find Preferences and select it. A new window should appear
-
In the new windoe find the section titled
GitHub Enterprise
-
For the field
URL
add https://github.ccs.neu.edu -
For the field
Login
add your CCIS GitHub login name; the same name you email the course staff on Piazza -
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.
-
lab1-<login>
-
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.
-
Click on the
lab1-<login>
repository. -
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.
-
Open your git application.
-
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.
-
-
The Git application will ask you where to download the repository on your local machine. Select a folder of your choice.
-
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
-
Open DrRacket and in the definitions window add the following text
; This is my first DrRacket comment
-
Save this file inside the same folder as the one we download from the CCIS GitHub server with the name
lab1-git-test
. -
No go back to your git application and from the left panel select your
lab1-<login>
repo. -
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.
-
At the bottom of the git application’s window there are 2 text boxes and a button with the text Commit to master.
-
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
-
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
-
Click on Commit to master.
-
Select the repository
lab1-<login>
from the left panel. Right click on it and selectView 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. -
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.
-
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.
2. DrRacket Functions
A classmate came up with a function to calculate a 20% tip for his restaurant bill. Here is his code
(define (tip amount)
(* amount 0.20))
Another classmate wants to use this function as well but they would like to choose the percentage to use for a tip every time.
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.
3. Making decisions
Your tip program is getting very popular. People are asking for extensions to the program. One popular extension is the following.
-
When the bill amount is less than or equal to $100 then the tip percentage is 15%
-
When the bill amount is greater than 100 but less than 400 the tip percentage is 20%
-
When the bill amount is greater or equal to 400 the tip percentage is 22%
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.