PSA 0: Warm up


5/5 - (2 votes)

PSA 0: Warm up

Welcome to your first CSE 8A assignment! The purpose of this assignment is to get you grounded and
ready to start writing programs in CSE8A. The goals are for you to get comfortable with Dr. Java, and to
get comfortable using your cs8a account to develop your programs and submit your assignments.
Required Skills: Chapter 2 and Chapter 3 up to page 70.
This PSA is worth 10 points total, allocated as described in the assignment instructions below. As
described in class, you may complete at most 4 of the quarter’s programming assignment using
pair programming. If you have decided to work in pairs, please review the guidelines for pair
programming. In addition, note the following details about working with a partner:
■ For this assignment, if you decided to work in pairs, find a partner before you start on the
assignment. Or else, you have violated the policy on pair programming.
■ You will submit only ONE version between the two of you though your group can submit as
many times as you want to.
Starter code: LINK HERE
Helpful Information:
Online Communication: Using Piazza, Opening Regrade Requests
Getting Help from Tutor, TA, and Professor’s Hours
Lab and Office Hours (Always refer to this calendar before posting.)
Academic Integrity: What You Can and Can’t Do in CSE 8A
Remote Lab Access and File Transfer Guide or Yingjun’s Piazza Post
Want a Higher Grade in this CS Class?
Table of Contents:
Part 0: Ways to get help [0 Points]
Part 1: Research agreement, and Academic Integrity Agreement [2 Points]
Part 2: Your first program! [8 Points]
Getting started
Copy, Compile, Debug, and Run!
Problem Solving Assignment
Star point (Completely optional)
Submitting the Assignment
Part 0: Ways to get help
(You won’t be graded on anything in this part. It’s for your information only. But we expect you to
understand and be familiar with this platform, so take a few minutes to do this part)
The best ways to get help in this class are :
(1) to go to the lab and seek help from a tutor or
(2) if you have a simple question, to post it on the discussion forum. Hopefully you’ve already found the
lab, but if not, you should probably go there. Also, if you haven’t tried logging into the Piazza discussion
forum yet, now might be a good time:
You should always use the discussion forum for any electronic question that is not personal/sensitive in
Please refer to the syllabus for the (rare) instances where you should send your professor or tutors email.
But for almost everything, post to the discussion forum.
A couple of rules to keep in mind when posting:
■ NEVER post your code, unless you make your post private. Posting your code in a public post
is a violation of the integrity of scholarship policy for this course and may result in a
deduction in your grade or university sanctions.
■ If you have an involved question (e.g., “how do I start on the assignment”) it is best to get help in
person, and we may tell you as much in our response to your post if you post such a question.
Part 1: Research agreement, and Academic Integrity
Agreement [2 points]–INDIVIDUAL
You must do this part individually, without your partner.
The two (2) points are for stating whether or not you agree to participate in a research study we are
conducting as part of this class. You won’t have to do anything special to participate, and your data will
remain completely confidential. More information can be found on the consent form linked below. You
get this 2 points for explicitly agreeing or disagreeing to participate. If you don’t fill out this agreement at
all, we will assume you do not agree, but you will not get the 2 points:
Link to informed consent form
You MUST also read and electronically sign the CSE 8A Integrity of scholarship agreement before going
any further. Integrity of scholarship is a critical part of this course. Failing to do so will result in grades
of 0 until you sign the agreement. If you have any questions or are unsure about how any part of this
agreement applies to CSE8A, please ASK your instructor. Most cases of academic dishonesty occur
because a student had not taken the time to understand the policy.
Link to electronically sign the Integrity of Scholarship agreement
Part 2: Your First Program! [8 points]
How to Get Started
These instructions assume you are working in the lab machines in B230. We recommend that you
work there but with 450 of you, we understand there might not be enough room. So if you don’t want to
go to lab you have two options: (1) Connect remotely to the lab machines and run your code there. This
guide will help you get started with that. (2) Install Dr. Java on your own machine. The setup guide under
Part A below will help you with that.
You need to set up/start three things:
A) Set up the programming environment (Dr. Java);
B) Set up the assignment folder;
C) Follow the instructions on how to compile your first Dr. Java project.
Details for each of these steps are given below.
A) Set up the programming environment
Instructions on how to set up Dr. Java to use the bookclasses libraries can be found at this link:
B) Set up Assignment folder
Instructions for working on the lab machines
If you are working in the lab, or remotely connected to a lab machine, follow the instructions here. If you
are working on your own machine (NOT connected to the lab machines), skip to the alternate
instructions below:
1) Right-click in an open space on the Desktop and select ‘Open in Terminal’ from the drop down menu.
(it will bring up the following window)
2) Highlight the following 5 lines with the mouse one line at a time, and right click to copy from this
webpage, and then right click -> paste in the terminal window and hit return (i.e. highlight “cd ~”, copy
the single line, paste it into the terminal, hit return in the terminal, come back here, copy the single line
“mkdir Assignments”, paste it into the terminal and so on) OR type the lines one by one :
cd ~
mkdir psa0
cd psa0
cp ../../public/psa0/ .
Note: Be sure not to miss the “.” at the end of the 6th line! That’s actually important! If for some
strange reason these commands don’t work, you can also access the required assignment files at the
bottom of the assignment page. However, be advised that being familiar with these commands is
critical to being a strong programmer!
Side note: These commands might seem like magic, but they are actually commands for an operating
system called Unix that tell your computer how to organize your files. You will learn more about Unix as
the term progresses and in CSE 8B, but if you are curious, here is what each line does:
Command Description
cd ~ Change into your home directory. cd stands for
“change directory” and ~ is the symbol for your
home directory.
mkdir psa0 Make a new directory (folder) inside the current
directory (home) that will hold your files for psa0
cd psa0 Change into this newly created psa0 directory
cp ../../public/psa0/ . Copy the file in the location
“../../public/psa0/” to your
current directory. cp is short for “copy”. .. means
“go up one level”, and . means “the current
directory”. So you are saying take the file that
can be found in the directory 2 up from where I
am, and then down into public, then down into
psa0 named and copy it to my
current directory.
ls List the files in the current directory. ls is short for
3) Select the terminal window with the mouse and right-click to paste.
4) Verify that the ‘’ file is shown as the result of the last command (you may have to
press Enter).
Following these procedures, your file will be named correctly and be located in the correct places. For
every assignment you need to follow correct naming assignments in the correct locations to get credit
for your work.
5) Proceed to start your programming assignment.
Instructions for working on your Local Machine (Your Laptop/Computer):
1. Create a new folder named psa0.
2. Download the starter code for psa0 from this link: LINK HERE
C) HOW TO compile your first Dr. Java project: Copy, Compile, Debug and Run!
1. Open the file in Dr. Java. In it you will see the following code:
* (And then remove this top instructional comment)
* File Name:
* Created by: Shuaiqi Xia, cs8a3 and Tony Xia, cs8a4
* Due Date: Oct 8th, 2017
public class DrawMyName
// The line below is magic, you don’t have to understand it (yet)
public static void main (String[] args)
// This is some starter code, but it has errors. You will
// fix these errors and then add your code to draw your name
// here. Be sure to remove this comment once you’ve fixed the
// errors and started adding your own code.
World w = new World();
Turtle jose = new Turtle(200,100,w); //Creates a turtle in w at
//(x,y) (200,100)
//Make a U shape

2. Read through the file and talk with your partner, or reflect yourself. DON’T
CHANGE ANYTHING. What do you think this code is going to do?
3. Compile: The compile step translates the file in pseudo-english (Java code) to a
Java byte-code file (byte-code is the same “language” for all types of machines) called
■ Click on the “Compile” Button in Dr. Java (left of Reset on the top – right side)
■ AHA! This code will not compile. The compiler shows you an error which looks like this (the one
highlighted in yellow in the Compiler Output pane at the bottom) your line numbers may be
Compilation completed. The following files were not compiled
1 error found:
File: G:\Shuaiqi\Academics\CSE 8A Spring 2016\psa0\ [line: 23]
Error: ‘;’ expected
4. Debug: Here’s how to interpret this error:
■ The error is on line 23 in (That’s what the “File” line tells you), and it is
highlighted in yellow.
■ It is unhappy because you are missing a semicolon at the end of the line. Note that the error
tells you that (“Error ‘;’ expected”)
hit SAVE and COMPILE to find new errors. There are plenty of different reasons for
compilation errors, the messages will try to give you a hint of what may be going on.
5. Edit and Compile: To fix the error on line 23.
■ On the highlighted (yellow) line in the Definitions Pane (where your file is
shown), add the missing semicolon.
■ Click on Save. Click on compile.
■ Ah, there’s another error. This one seems a little trickier:
File: G:\Shuaiqi\Academics\CSE 8A Spring 2016\psa0\ [line: 25]
Error: method turnRight in class SimpleTurtle cannot be applied to given types;
required: no arguments
found: int
reason: actual and formal argument lists differ in length
6. Debug again: Here’s how to interpret this error:
■ The error is on line 25.
■ It is complaining because the turnRight method is not supposed to take an argument. Only the
turn method accepts arguments. It is telling you this when it says “required: no arguments”, that
is, the turnRight method is not supposed to accept arguments. “found: int”, that is, it found an
integer (90). You have two options for fixing this error. You can either remove the integer
argument, and simply call the turnRight method, which will turn the turtle 90 degrees to the right,
or you can change the method call to turn instead of turnRight, which will also turn the turtle 90
degrees to the right. It’s up to you.
■ Edit the file to fix it now, Save your code, and compile again. It should now compile without
7. Run: Let’s see what this code does. Now that it has successfully compiled, a DrawMyName.class file
exists in your folder. (You should see it listed if you hit refresh on that window). The DrawMyName.class
file contains the Java bytecode (something that is really not fun for humans to read) that the computer
can read to execute your program (in reality, it is interpreted by the computer to a series of 1s and 0s
which the computer can execute). HINT: You need to know the difference between .java files
and .class files and how and when .class files are created.
■ Click on run in Dr. Java (to the right of reset). Draw the output in your World window.
■ What’s wrong with this code? The first line for the U is going up, then over to the right. This is
because, by default, turtles START LIFE facing up. One way to fix it is to have the turtle start by
rotating to face down.
■ Add this line of code right after the “//Make a U shape” comment (but before any of the other
turtle direction lines):
jose.turn(180); //Face down
■ Save, Compile and Run. What does the output look like now?
■ Hey – we have a U! Congratulations!
Problem Solving Assignment
Finally! Here’s the part you will get credit for. Modify your DrawMyName program so that it does the
following, in the order listed. Note that some of these steps are already done at this point.
1. Create a World for your Turtle. (1 point)
2. Create a Turtle(s) in that World. (1 point)
3. Draw one of the first names in your group on the screen using the Turtle(s). Your name should look
similar to the example output, below, but you are encouraged to make it even more creative. However,
if both partners’ first names have fewer than 5 letters, you should proceed and draw one of your
cs8af login name until you reach 5 or more letters. (4 points)
4. Properly comment your code and place both partners’ names, logins, and the date in the header. (1
5. Finally, you earn a point just by submitting code that compiles! So make sure your code compiles
before you submit! (1 point)
6. If you are working with a partner, make sure that both you and your partner each have a copy of the
code after you’re done for future reference.
You are required to create at least one turtle and to draw your name on the screen. However, feel free to
be creative. You can use multiple turtles or have multiple colors if you want. (Hint: you can look through for interesting maneuvers the turtle can make).
Note: if your first name has more than 8 letters, you may just draw the first 8 letters.
Example Output
Your program should produce output that looks very similar to this, but displays your first name instead
of “CS8A FALL 2017”.
Note: You will include your partner’s first and last names and his/her cse8a login name. Follow the
example given in the starter file and modify it with your own details.
Star Point (Completely Optional)
If you’re gotten here and you still want more, we’re providing this “star point” option. However, this is
just a suggestion. Any significant extension or project will be considered for a star point. If you’re
interested, keep reading.
First, what is a “star point”? Star points are challenging, open-ended extensions designed to engage
those who really want to learn more and go beyond the basic requirements. However, these are not
extra credit. If you do “enough” star point and are “close enough” to the boundary, you may be moved
up to the higher grade, but do these star point extensions because you are intellectually curious and
want a challenge. Not for the grade. The course staff will not answer questions like “If I do this, will I get
a star point?”. If you are doing the star point extension just to get the star point, then you’re doing it for
the wrong reason. Only do it if you would be happy whether or not you get the point in the end.
This assignment’s suggested star point extension is to encourage creative thinking. The basic idea here
is to draw everything with minimal number of “pen-down”, meaning the turtle should not “pen-up” and
jump to certain location (it is, however, allowed between letters) or move on the same path more than
once while drawing out the letters. For example, the minimal number of “pen-down” for “CSE” is 4
where ‘C’ and ‘S’ have 1 minimal number of “pen-down” and ‘E’ has 2 minimal number of “pen-down”.
This way, we encourage you to think and design creatively before starting the assignment. Go and try it
out on the paper!
How to Turn in your Homework
Both enrolled and waitlisted students will be allowed to submit their homework.
Turn it in using the turnin script
1) Make sure your psa0 folder containing is inside the home folder/directory on
your lab server account (cs8af account). To get from your personal computer
to your lab account there are a few options.
a) scp (mac only) – Open the terminal. Assuming your psa0 folder is on your desktop, this
command will transfer the psa0 folder to your lab account. Replace the “xx” in cs8afxx
with your own account identifier.
scp -r ~/Desktop/psa0 [email protected]:~/
[You will be prompted to enter the password to your cs8af account]
This command reads: Make a copy of the folder psa0 and its contents on your Desktop
to the home directory of your cs8af account.
b) WinSCP (for windows) – Download and set up using this guide, drag and drop the psa0
folder to the home folder on cs8af account.
c) Email yourself Connect to lab account with vncgnome using this
guide or go to the lab in person. Make a folder called psa0 in the home directory. Open
your email on Firefox to download and put your file inside the psa0 folder.
2) If you’re turning in work using a lab machine, open the terminal proceed to step 3. If you are
working remotely, you should use your terminal (or PuTTY) to ssh using ieng6-200, 201, or 202.
Unfortunately, ieng6 servers 240-259 do not support the turnin script at the moment and we are
really sorry for this inconvenience. To ssh, type the following in the terminal followed by the
password to your cs8af account. Replace the “xx” in cs8afxx with your account’s identifier.
ssh [email protected]
[You will be prompted to enter the password to your cs8af account]
After you have logged in, it should tell you to press space or enter to continue.
3) Navigate to the directory that contains your assignments. Your assignment folder should just be
in the home directory, so type the following commands and press the return key after each one
cd ~
cd ~ stands for change directory to your home directory. ls is short for list, which lists all files
and folders in the current directory. You should see the folder “psa0” listed after running the
command ls. If you see “psa0” listed, you can be sure that a folder called “psa0” is in your home
4) Now, to submit your homework, you will type the following command and press enter to run it.
cse8aturnin psa0
5) If every step is followed correctly, you should be able to see prompts in the terminal, asking you
to sign according to the Integrity of Scholarship Agreement.
6) Carefully read the prompt. When you are ready to sign, follow the steps in the prompt (with no
extra characters or spaces).
7) If you see the message “ Turnin complete”, you have successfully submitted the files.
Checking your submitted files using the turnin script
1) As described at the end of submission scripts, to later check that your archive is turned in,
simply type the following command in the terminal.
cse8averify psa0
Important Note
The turnin script would allow multiple submissions, but it would ONLY keep the most recent psa
folder that you submitted. The new submission would override the older one. Consequently, later on,
when you submit your PSAs, make sure the latest submission is the one that you want us to grade on.
Common Command Lines needed for submitting your PSAs:
ls (this command will show you the list of files/directories in the current directory.)
cd <directoryName> (To use this command, you will enter your directory name one “space” after
“cd”. This command will help you to enter the specified directory.)
cse8aturnin <psaFileName> (To use this command, you will enter your psa name one “space” after
“cse8aturnin”. The name of the psa file should be consistent to the one specified in the PSA write-up.
This command will help you to submit your psa folder.)
Example screenshot of a successful turn in:
Example of a verification of your turn in (successful)
Example of a verification of your turn in (unsuccessful)

PlaceholderPSA 0: Warm up
Open chat
Need help?
Can we help?