# teaching machines

## CS 148 Lab 1 – Madeup, Homework 0, and Project Euler

Welcome to the first lab of CS 148!

In the first half of today’s lab, we’re going to explore a language for making 3D models. We won’t be using this language for anything else in the semester, but it gets us thinking about programming in a visual way. We’ll start with a quick demo.

In the second half, we’ll get into Java, IntelliJ, and your course project on GitLab.

### Protocol

Lab is a time intended for you to work on programming exercises in a low-stakes environment and with lots of help at your disposal. Read each of these out loud with your lab partner and check them off to acknowledge your understanding:

• You complete a few checkpoints, which consist of short programming exercises.
• Questions are always fair game. Your instructor and teaching assistant are here to help.
• You work with a partner of your choosing, but this must be a different person each week. Talking through technical matters with other human beings is a key part of lab.
• Groups of three are not allowed except by permission from the instructor.
• You work at one computer only.
• One person types for the first exercise. The other for the second checkpoint. And so on.
• Both you and your partner must be present during checkoff time to receive credit.
• Checkpoints are only checked during lab, not during office hours or over email.
• If you don’t finish your checkpoints during a lab meeting, you can complete your work before next lab and get checked off during the first 10 minutes of the subsequent lab. No credit is granted if the work is not already complete before lab starts.

Many of these rules were crafted out of failures from earlier offerings of this course. These are designed to maximize the number of passing grades at the end of the semester.

### Checkpoint 1

In this first exercise, we’ll use Madeup, the 3D programming language that your instructor demonstrated at the beginning of lab. Here’s the polyring program that we wrote:



moveto 0, 0

n = 7

repeat n
move 2
yaw 360 // n
end

nsides = 5
dowel

var mupDiv = jQuery('#mup_dowel');
mupDiv.closest('pre').replaceWith(mupDiv);
document.getElementById('mup_form_dowel').submit();

moveto 0, 0

n = 7

repeat n
move 2
yaw 360 // n
end

nsides = 5
dowel



This program demonstrates two foundational ideas in computer science:

• named data, which give meaningful descriptions of the “atoms” of our program and which allow us to write symbolic, generalized algorithms
• loops, which make mind-numbing repetition more mind-zapping

For your first checkpoint, you will apply these ideas to generate two other models.

#### Model B

Person B types. Visit Madeup in a new tab.

This symbol is used in the United Kingdom to mark a mechanic’s shop that can certify that your vehicle passes certain standards required by the government.

Notice the model has rounded corners instead of sharp bends. These were automatically added by appending a named parameter to the dowel command:

dowel maxBend:1


Use only a single yaw command per bend—instead of a sequence of turns like in the chain link—and then let the dowel command smooth it out.

When you have completed your two models, invite your instructor or teaching assistant over to offer feedback and make note of your accomplishment in the gradebook. If your instructor and TA are working with others at the moment, and you are confident that you’ve satisfactorily completed this checkpoint, please move on to the next checkpoint and catch them when they become available.

### Checkpoint 2

We now leave Madeup and switch to a language that we will use most of this semester: Java.

In this course, we ask you to use IntelliJ IDEA to write and run Java code. IDEA is one of many possible tools we could use to write Java. Netbeans and Eclipse are also quite popular. There is no single best tool. We choose IDEA because it has an accommodating license and is widely used in industry.

Your code this semester will be stored in a project hosted on GitLab.

To get your project set up, please run through homework 0, which is linked on the course page. (I’m not linking it here because it’s important to me that you know how to navigate this site. Sorry to be a jerk!)

Now let’s create some new code. Start by creating some new packages for our lab work:

• Right-click on the src directory and create a package named labs.
• Right-click on the labs directory and create a package named lab01. (Note the leading 0. We’ll reach double-digits in this class, and the leading 0 will ensure that they stay properly sorted.)

Everything’s in place. Let’s solve some problems.

#### Problem A

Person A types. Visit Project Euler and register to create an account.

Pick one of the problems. Work out an algorithm on paper or markerboard in pseudocode. Then create a new class in lab01 named ProblemA. Translate your pseudocode to Java. Submit your answer to Project Euler. Fix your code until you have solved the problem.

#### Problem B

Person B types.

Pick a second problem, and solve it with the same process. Write your code in class ProblemB.

Once your solutions are working, show your work to your instructor or teaching assistant. Commit and push your work to GitLab. Then log out and go do something amazing.