CS 151 - Lecture 1

Cover page image

Cay S. Horstmann

CS 151

The Textbook

What? No Lectures?

peter-norvig-lecture

What You Need to Succeed

Prerequisites
Time
Laptop

Questions

questions

Plagiarism and Cheating

cheating

Git

Octocat

Adding

Things To Do Today

Lab

lab

A Simple Programming Problem

  1. Solve this simple problem: In Java, implement the method Arrays.swapLargestAndSmallest(int[] a) that swaps the largest and smallest element in a. If there are multiple largest or smallest elements, pick the first one.
  2. Check your answer in CodeCheck.

Bash

Gnu-bash-logo

Git

2color-lightbg

Adding to the Repository

  1. Open a terminal and change to the directory into which you cloned the repo:
    cd cs151
    
  2. Make a subdirectory lab1:
    mkdir lab1
  3. In that directory, make a file Arrays.java:
    touch lab1/Arrays.java
    
  4. Open the file with your favorite text editor and paste in the solution to the simple programming problem. If you couldn't solve the problem, just put in the outline from CodeCheck.
  5. Add the file: Type
    git add lab1/Arrays.java
  6. Commit all changes: Type
    git commit -a -m "Added lab1"
  7. Push to BitBucket: Type
    git push origin master
  8. In the BitBucket web interface, locate Arrays.java
  9. Did you find it? Hooray—you have just reached level 2.
  10. Those three commands—add, commit, push—are all you need to know about Git to complete homework 1.

Be The Grader

be-the-computer

  1. Check out your repo into a temporary location (which we'll call the grader repo). Replace yourname with your BitBucket user name.
    cd /tmp
    rm -rf cs151
    git clone git@bitbucket.org:yourname/cs151.git cs151
    
  2. Do what the grader would: Compile and run the program on the command line.
    cd /tmp/cs151/lab1
    curl -O http://horstmann.com/sjsu/spring2019/cs151/day1/Tester.java
    javac Tester.java
    java Tester
    
  3. Did it work? If not, why not? Ponder what the grader will do when it doesn't work the first try. (Hint: Nothing.)
  4. If it didn't work at the outset, fix your issues in your student repo. In another terminal, push the changes to your student repo. In the terminal in which you are the grader, run git pull. Try compiling and running again.
  5. Add the compiler and tester output to a file lab1/report.txt in your student repo (not the grader repo). Put in your and your buddy's name.
  6. Add the file, commit, and push.