Lab 1, CSC 2001, Fall 2026
1 Creating a GitHub account
Open a browser (I don’t recommend Chrome; how does Google actually make money? Think about it .... To be honest, though, I’m a biased former employee of Mozilla, telling you to download Firefox.)
Go to github.com
Create an account. I recommend using your cal poly address. You can always create a totally different account for your personal projects? (You can definitely use an existing account, if you like.)
To create a new repository from a template, go to
https://github.com/cp-csc2001/csc2001-template .
Click on the "Use This Template" > "Create a new repository"
Name your new project "CSC 2001 Lab 1".
Enter a description for the project.
Choose "Private" for your repository.
(I’m actually not sure how many private repos you can create... at least until you tell GitHub that you’re a student.)
click "create repository".
Hey! You have a repository! It’s set up as a Maven project, which means that it’s absolutely chock full of mysterious files whose purpose is opaque. If you want, you can click around in the GitHub web interface to see what’s in those files. Interesting!
2 Installing GitHub Desktop
Download and install GitHub Desktop, from
https://github.com/apps/desktop
(Yeah, sorry, that’s not very detailed.)
Choose File > Clone Repository
Find your new repo, make a note of the "Local Path" box, which shows where GitHub Desktop is planning to put it on your machine (we’ll need that later), and click "clone".
Before doing any work on the repo, we need to set up the IDE....
3 Downloading and Installing IntelliJ IDEA
Go to
https://www.jetbrains.com/idea/
click download link
if your platform requires a choice (e.g. macOS requires choosing apple Silicon or Intel), choose your platform.
Download
use installer
start IntelliJ IDEA
Read End-User License agreement carefully!
Consider suing somebody, then sigh deeply and decide against it.
But if you’re allowed, you’re going to vote in the next election, right?
Right?
On welcome pane, click "Take a quick onboarding tour / Start Tour in Java"
... Go through the tour. (No need to let IDEA access bluetooth, though, geez.)
After the IDE shuts down the big window, click "Open Project".
Navigate to the directory you created earlier with GitHub Desktop, that I told you to make a note of.
IntelliJ will ask whether to trust the project that you’re opening. Since you’re writing all of the code in it, the answer is probably "Trust Project".
This next one needs to be fixed:
If JDK 25 is not listed as available, use "Download JDK" to download the Microsoft OpenJDK 25 (point whatever).
In the Project Window, open the ‘src/main‘ directory, and you’ll find a ‘Main‘ file way down in there. Double-click to open it, take a quick look at it, and then click the green "run" triangle (the way you did before in the tour) to run the program. You should see a window at the bottom appear, a bunch of mysterious "compile" stuff happen, and then some output, including "Welcome" and the numbers seven through eleven.
This file contains a main function, which happens to call an "addSix" function. Take a look at that function.
Next, in the project window, navigate to the ‘src/test‘ directory, and you should find a ‘MainTest‘ file nested inside. Open this file, take a look at it, and then click the triangular green "run" button. This time, instead of running the main function, IntelliJ compiles and runs the test. You should see a green bar, and a message that the test passed.
4 Writing a function
Next, let’s write a function that adds seventeen to a number.
Following the pattern of the ‘addSix‘ function, write your own function called ‘addSeventeen‘. It should have a purpose statement just like ‘addSix‘, and a test case in the MainTests file.
When you’re done, try running the tests again; this time, you’re hoping to see "2 tests passed".
This is a good point to emphasize that THINGS WILL BREAK. That’s okay! Life as a programmer means constantly making mistakes, and constantly working to fix them. Talk to your neighbor, talk to your instructor, talk to lots of people!
5 Saving, Committing, Pushing
Once you’ve written the addSeventeen function, it’s time to commit and push your code back up to GitHub.
First off, let’s observe the current status. Go back to the github website, navigate to the repository that you cloned, and notice that none of your changes are there.
Next, open the GitHub desktop App. It should show that you have two changed files, Main.java and MainTest.java. Click in the "Summary (Required)" box, and summarize the changes. You can click on the files in the changed list above, if you want to see the changes. Enter a meaningful summary; in this case, it might be something like "added addSeventeen function". Then click the "Commit <n> files to main" button.
First off: good job, you added a commit to the repository.
But also: if you go to the GitHub website, you’ll see that your files are *not* there, even you refresh a lot. That’s because after committing your changes to your local repository (on your computer), you need to "push" those changes up to GitHub.
There’s probably a big blue button that will allow you to push; you can also use the "Push Origin" black button at the top of the window, this is probably a more reliably present button.
Now, if you go to the GitHub website, you should be able to see that your changes are there. Check it!
6 Writing a bunch more functions ...
For the remainder of this lab, we’re going to be writing some small functions on strings. Specifically, these functions will "encrypt" strings, following patterns that you discover. I say "encrypt" in quotes because these encryption schemes are NOT VERY SECRET. If they were, you probably wouldn’t be able to figure them out!
First off, go to
https://handin-1.brinckerhoff.org/csc2001-lab1/
Make sure that encryptor "A" is chosen, then enter a string in the box, and hit "go" (or just press return). You will see the string’s encryption!
Can you figure out the difference between the given string and the encrypted string? You probably can.
Next, your task is to write the corresponding decryptor. That is, you will write a java function that can take the encrypted string, and return the unencrypted version.
Your function does *not* have to detect or handle strings that are not outputs of the corresponding encryption function. So, for instance, if the encryptor always produces strings of an even length, your function does not have to detect or handle strings that are of an odd length.
Following the pattern above, you should develop this function in the ‘Main‘ and ‘MainTests‘ files.
Follow the design recipe. This means starting with a purpose statement and a header (the first line of the function), then writing tests. In this case, writing tests is easy; every example string you typed into the website is a (reversed) example for the decryptor. That is: calling your decryptor with the shown "encrypted string" should return the corresponding "given string". Translate three examples into test cases. Do this *before* implementing the decryptor function.
To be slightly more specific: your function implementations (the part in the ‘Main‘ file) should contain a body which is deliberately incorrect, just to make it possible to run the code. Specifically, the body of each function should initially just return the string "BOGUS", to make sure that the test cases can run (and fail).
After writing the purpose statement, the header, and the tests, go ahead and write the body of the function; with luck, your tests will eventually pass. Again: you will make many mistakes, and then fix them one by one: this is not only okay, it’s important; if you don’t make these mistakes and fix them, you’ll probably have a very hard time writing code on the quizzes and tests.
After finishing the decryptor for part A, check in with an instructor or lab assistant. Once you get the thumbs-up, continue on with the remainder of the decryptors. Ask lots of questions!
This idea is taken from a pyret lab from DCIC (Krishnamurthi et al.)
7 Optional
Some of these problems are optional! Talk to your instructor about which ones are required. The "XA" and "XB" encryptors should definitely be considered optional.