CS 142 Lab 1
Part A: Leroy and the Cookies
In Part A, you will play a game already written for you in Java. Through playing the game and investigating the code, you will practice with Java variables, if statements, and loops.
Getting started (preferred way)
Start IntelliJ. From the screen that appears, choose “Get from VCS.”
In the URL box, put
https://github.com/pkirlin/cs142-f24-inclass
.In the directory box, choose a folder to store your project. Note that you will re-use this particular project throughout the class, so make sure you know where it is.
Click “Clone.”
Click “Trust Project” if prompted. Choose to open the project in a new window if prompted.
In the left-hand panel, find the
src
folder and expand it. This is where your Java files should reside. You should see three files there.Skip below to “beginning the lab.”
Getting started (if above method doesn’t work)
Start IntelliJ. From the screen that appears, choose “New Project.”
On the “New Project” screen, pick a name for your project, for example “lab1.”
It’s easier if it doesn’t have spaces in it.Choose a location for your project. I suggest making a folder dedicated just to CS142 projects, and then storing your project in this folder.
If the “JDK” section of this screen says “No JDK”, click the dropdown box and choose “Download JDK.” Pick version 18, and the Oracle vendor. Click “Download.”
Unselect the checkbox for “Add sample code.”
Once the JDK is downloaded, you can click “Create” to create your project.
Download the following three files to your computer (make sure you know where they’re being downloaded to):
(This may involve right-clicking and choosing “Save As” or “Save Link As”) depending on your operating system and browser.
In the left-hand panel, find the
src
folder. This is where your Java files should reside. Find the three files above on your computer and drag-and-drop them into thesrc
folder in IntelliJ.
Beginning the lab
In the left-hand panel, double-click on
LeroyAndTheCookies.java
. Click the “run” button (green triangle) in the upper-right area of IntelliJ to run the Java code. If it doesn’t run, ask for help.Now you’re ready to start the lab!
In the left-hand panel, double-click on
LeroyAndTheCookies.md
. Follow the instructions in this file. This is where you will answer the questions for the lab.
Part B: One Is Zero
After you finish Part A, try to write the second program from our previous class, “One is Zero.” Directions are in the OneIsZero.java
file (or see the class webpage or your handout.)
Submitting the lab
At the end of the lab session, upload the two LeroyAndTheCookies
files to canvas. Also include OneIsZero.java
if you made any progress on that.