💿
CS61B Fall 2022
  • CS61B Fall 2022
  • Prerequisites to running the assignments.
  • Lab 01: Setting up your computer
  • Lab 02: JUnit Tests and Debugging
  • Project 0: 2048
  • Lab 03: Timing Tests and Randomized Comparison Tests
  • Lab 04: A Debugging Mystery
  • Project 1: Deques
  • HW 2: Percolation
  • Lab 07: BSTMap
  • Project 2a: NGordNet (NGrams)
  • Lab 08: HashMap
  • Project 2b: NGordNet (WordNet)
  • Lab 11: BYOW Introduction
  • Project 3 BYOW
    • Phase 1: World Generation
Powered by GitBook
On this page

Lab 01: Setting up your computer

PreviousPrerequisites to running the assignments.NextLab 02: JUnit Tests and Debugging

Last updated 1 year ago

Instructions:

Solution:

A lot of reading about setting everything up, then you're encouraged to implement the int nextNumber method in Collatz and make bool isLeapYear return true, optionally implementing it.

Easy tasks to make sure everything's working as it's supposed to.

Solutions:

public static int nextNumber(int n) {
    if (n == 1) {
        return 1;
    } else if (n % 2 == 1) {
        return (3 * n) + 1;
    } else {
        return n / 2;
    }
}
public static boolean isLeapYear(int year) {
    // Optional
    return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
https://fa22.datastructur.es/materials/lab/lab01/
https://github.com/tomthestrom/cs61b/tree/master/lab01