Remember to create a new directory in your repository for this lab.
$ cd CNET-cs152-spr-18 $ mkdir hw2 $ svn add hw2 $ cd hw2
Beginning in lab 2, some students will spend lab time in Duet Programming. Read this short introduction to Duet Programming. Create a new file in your hw2 directory named lab2questions.txt and add it to the repository. A quick way to do this is to use the unix command touch. This will create and empty file and give it a name. Then you can add it to the repository. This way, when you commit later, you don't need to remember to add it!
$ touch lab2questions.txt $ svn add lab2questions.txt $ vi lab2questions.txtNow copy and paste the following questions into the file. Fill in the answers as you go through the pre-lab.
Test-Driven Development is a software engineering approach that encourages developers to spend more time in concrete tasks in the planning phase in order to produce code with fewer bugs (therefore reducing debugging time). As you will no doubt find out in this class, debugging is by far the least fun part of programming. Design and implementation are far more pleasurable. So the more we can put time and energy into those phases, the less frustrating your quarter will be.
Fill in the answers as you read the wikipedia entry on Test-driven Development.
During the warmup, you are going to implement several functions that exercise control, iteration, and recursion.
In order to spend your time efficiently in lab, you need to start with a
skeleton that compiles. Then you can start on development right away with
the TAs there to help you.
This time, I have given you the complete skeleton of one file:
warmup2_main.c.
I have given you a start on warmup2.h and
warmup2.c, but you need to complete the skeletons prior to lab.
Remember to only implement the parts necessary to make it compile.
Given a number, print the corresponding capital letter of the alphabet. The number can be anything from 0 to 25. 0 prints out 'A', 1 prints out 'B', 2 prints out 'C', etc. It also returns the character.
Given a character, print the corresponding upper-case letter of the alphabet using asterisks. The letter can be 'R', 'S', 'T', or 'U'. The set of letters are here.
void draw_sideways_wedge_rec(unsigned int width, unsigned int height);
draw_sideways_wedge_rec(3,10) results in:
*** **** ***** ****** ******* ******* ****** ***** **** ***
Draw a sideways wedge iteratively. The functionality is identical to draw_sideways_wedge_rec, but you may not have any function calls (other than printf) within the function.
void draw_sideways_wedge_iter(unsigned int width, unsigned int height);
We're going to start using a Makefile. This makes it so that you can store your compile line and not write it every time. In addition, it detects when / what files need to be recompiled (if you have a large project). Create your Makefile to compile your code.
$ touch Makefile $ svn add Makefile $ vi Makefile
You need a name of the target, the files on which it depends, and the exact compile line. We will name our target warmup2. Put the name of the target first, followed by a colon. Then list all of the files that, if one changes, would require recompiling the code. On the second line, you begin with a tab (not spaces) and type the exact compile line. Notice that warmup2.h is in the dependency list, but it's not in the compile line. .h files are never in the compile line.
warmup2: warmup2.c warmup2_main.c warmup2.h clang warmup2_main.c warmup2.c -o warmup
Make sure that it is a tab before the word clang, not just spaces.
Now you are ready to use your Makefile!
If this is the only thing in your Makefile or if it is the first target listed, then you compile with:
$ make
Otherwise, compile with:
$ make warmup2Throughout this course, we'll gradually add things to the Makefile. Pay attention - we will begin expecting you to write your own Makefile later in the course. You need to pay attention to the compile lines themselves, how to format the Makefile, and how to run the Makefile.